【问题标题】:OrbitControls.js - Cannot read property 'prototype' of undefinedOrbitControls.js - 无法读取未定义的属性“原型”
【发布时间】:2015-07-01 10:13:12
【问题描述】:

我在 Three.js 中启动一个项目,并且我已经正确导入了库 OrbitControls.js,但是当我打开控制台进行测试时,我看到以下错误:

Cannot read property 'prototype' of undefined

而且和OrbitConstrols.js里面的下面一行代码有关:

THREE.OrbitControls.prototype = Object.create( THREE.EventDispatcher.prototype );

我发现了类似的例子来研究这个问题的解决方案,比如this one,但它是为 Typescript 制作的。

您知道解决此问题的可能方法吗?或者它只是库的一个错误,即使我收到错误,对象也会正确呈现?

【问题讨论】:

    标签: javascript html three.js


    【解决方案1】:

    我不知道您是如何在 HTML 中添加它的,但是在添加 OrbitControls 时,顺序很重要,因为它需要 Three.js 中的某些东西。

    应该是

        <script src="../build/three.min.js"></script>
        <script src="js/controls/OrbitControls.js"></script>
    

    这些示例是找出问题所在的最佳方法 - threejs.org/examples/misc_controls_orbit.html

    【讨论】:

    • 是的,那是我的问题!感谢您的帮助好友:)
    猜你喜欢
    • 2020-05-13
    • 2021-08-01
    • 2021-10-30
    • 1970-01-01
    • 2022-07-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多