【问题标题】:How to create new Markup Tool in Markups Core Extension?如何在标记核心扩展中创建新的标记工具?
【发布时间】:2020-07-07 07:50:06
【问题描述】:

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

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 的代码示例,就像上面的文档说的那样。谁能帮帮我?

【问题讨论】:

  • 嗨,你有没有让任何东西工作,我们处于相同的位置,创建自定义编辑工具的信息不多

标签: autodesk-viewer autodesk


【解决方案1】:

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

你可以参考它的完整版源代码here...

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

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;
//...
}

或者您可以简单地在您的扩展程序中创建对标记工具的引用,以保持您自己的扩展程序独立:

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

【讨论】:

    猜你喜欢
    • 2021-01-30
    • 2019-03-28
    • 2017-08-03
    • 1970-01-01
    • 2012-01-08
    • 2013-12-29
    • 2013-06-17
    • 1970-01-01
    • 2020-06-03
    相关资源
    最近更新 更多