【发布时间】:2016-08-30 08:39:11
【问题描述】:
我似乎无法使用 threejs npm build 和 browserify 实例化 THREEjs 对象。
var THREE = require("three-js");
var camera = new THREE.PerspectiveCamera( 75, 1, 20, 2250 );
这会引发错误
bundle.js:24 Uncaught TypeError: THREE.PerspectiveCamera is not a constructor
可以看到bundle.js中存在构造函数
THREE.PerspectiveCamera = function ( fov, aspect, near, far ) {
THREE.Camera.call( this );
this.type = 'PerspectiveCamera';
this.fov = fov !== undefined ? fov : 50;
this.zoom = 1;
this.near = near !== undefined ? near : 0.1;
this.far = far !== undefined ? far : 2000;
this.focus = 10;
this.aspect = aspect !== undefined ? aspect : 1;
this.view = null;
this.filmGauge = 35; // width of the film (default in millimeters)
this.filmOffset = 0; // horizontal film offset (same unit as gauge)
this.updateProjectionMatrix();
};
当我从工作版本中移植这段代码时,我怀疑我可能在 Browserify 上做错了什么。
npm Threejs 构建版本 79
【问题讨论】:
标签: constructor npm three.js browserify