简体   繁体   English

Three.js:如何返回3D对象的脚本?

[英]Three.js : How to return the script of a 3D Object?

I'm playing with three.js and especially the Editor where you can attach Script on 3D object. 我正在使用three.js ,尤其是编辑器,您可以在其中将脚本附加到3D对象上。 In Unity 3D you can access a script by using something like : 在Unity 3D中,您可以使用以下命令访问脚本:

targetGameObject.GetComponent (scriptName).targetVariable;

How can you do this with three.js ? 如何使用three.js做到这一点

If I understand correctly, "Scripts" aren't a fundamental component of ThreeJS -- not in the same way as they are in Unity3D. 如果我理解正确的话,“脚本”不是ThreeJS的基本组成部分–不同于Unity3D中的脚本。 ie, The "scripts" in ThreeJS Editor would be better off named "scripting code" or something like that. 即,ThreeJS编辑器中的“脚本”最好命名为“脚本代码”或类似名称。 When you publish your app, these script functions get exported to JSON as strings and get evaluated upon their associated events -- but no tangible "Script" object/component actually results from them. 当您发布应用程序时,这些脚本函数将作为字符串导出到JSON,并根据其关联事件进行评估-但实际上并没有从它们中产生有形的“脚本”对象/组件。

In other words, the "Scripts" you're referring to in Unity3D would be something you would have to build out yourself or use an existing library. 换句话说,您在Unity3D中所指的“脚本”将是您必须自己构建或使用现有库的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM