如何在标记核心扩展中创建新的标记工具? [英] How to create new Markup Tool in Markups Core Extension?

查看:78
本文介绍了如何在标记核心扩展中创建新的标记工具?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Autodesk Forge Viewer中具有用于3D模型的标记扩展.我需要在Markups Core中创建一个新的扩展工具以添加到我的模型中,但是我阅读了文档以创建一个新的Markup Tool,但它对我没有帮助,我发现的唯一东西是它:

I have a markup extension in Autodesk Forge Viewer for 3D models. I need to create a new extension tool into Markups Core to add in my model but I read the docs to create a new Markup Tool and it not help me, the only thing i found is it:

Advance concepts
Create a new drawing tool (a new EditMode)
Developers are encourage to implement drawing tools not included in the Markups extension.
Every drawing tool must have a set of classes to handle them. Let's say for example we are implementing a
Panda tool. For a Panda tool we would need to add the following files/classes:

MarkupPanda.js
EditModePanda.js
CreatePanda.js (Action)
DeletePanda.js (Action)
SetPanda.js (Action)
MarkupPanda.js would contain the class MarkupPanda which extends
Markup and provides the code to render the
markups as an Svg and in a href="http://www.w3.org/TR/2dcontext/">www.w3.org/TR/2dcontext/ canvas 2d context.

EditModePanda.js would contain the class EditModePanda which extends
EditMode and provides the code
to handle user-input for creating a MarkupPanda onscreen.

CreatePanda, DeletePanda and SetPanda are classes that extend
EditAction and provide mechanisms to
author markups of type MarkupPanda.
By encapsulating these operations in actions, the Markups extension is able to make sure
that the undo and redo system handles them gracefully.

但这对我没有帮助,我没有找到任何有关如何创建新EditMode的代码示例,如上面的文档所述.有人可以帮助我吗?

But this not help me, I didn't find any examples of code about How to create a new EditMode like the docs say above. Anyone can help me?

推荐答案

关于标记工具,有一个简短的教程和一些额外的文档,

There's a brief tutorial and some extra doc on the Markup tool available here ...

您可以在此处参阅其源代码的完整版本. ...

通常不知道您现在遇到的确切问题,您可以按照以下模式扩展标记工具:

Not knowing the precise issues you've got at hand now generally you can extend the markup tool following the pattern below:

function YourExtension(){
//...
this.viewer.loadExtension("Autodesk.Viewing.MarkupsCore").then(ext=>{
YourExtension.prototype = Autodesk.Viewing.Extensions.Markups.Core.prototype;  
YourExtension.prototype.constructor = Autodesk.Viewing.Extensions.Markups.Core.prototype;
//...
}

或者您可以仅创建扩展中对标记工具的引用,以保持自己的扩展独立:

Or you can simply creeate a reference to the markup tool in your extension just to keep your own extension independent:

function YourExtension(){
//...
   this.viewer.loadExtension("Autodesk.Viewing.MarkupsCore").then(ext=>{
   this.markupTool = ext
   }
//...
}

这篇关于如何在标记核心扩展中创建新的标记工具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆