【发布时间】:2019-10-24 14:11:47
【问题描述】:
我需要知道如何使用 Type 脚本将网格添加到 Forge Viewer v6。
我浏览了所有主题和文章,它使用的是 v4。
现在当我尝试以下代码时:
private wallGeometry: THREE.BoxBufferGeometry;
drawWalls() {
this.wallGeometry = new THREE.BoxBufferGeometry(4000, 4000, 100, 1, 1, 1);
console.log('creating wall geometry');
this.wallGeometry = new THREE.BoxBufferGeometry(4000, 4000, 100, 1, 1, 1);
console.log('creating wall material');
let wallMaterial = new THREE.MeshPhongMaterial({ color: 0xff0000 });
console.log('register wall material');
this.viewer.impl.matman().addMaterial(
'dasher-material-vertex',
wallMaterial,
true);
console.log('create Overlay Scene');
this.viewer.impl.createOverlayScene(this._overlayScene, wallMaterial);
console.log('wall mesh');
this.wall = new THREE.Mesh(this.wallGeometry, wallMaterial);
this.wall.position.set(0, -1000, -2000);
console.log('add overlay to scene');
this.addToScene(this.wall);
}
private addToScene(obj: THREE.Object3D) {
this.viewer.impl.addOverlay(this._overlayScene, obj);
this.viewer.impl.invalidate(false, false, true);
}
我收到以下错误消息:
THREE.Object3D.add:对象不是 THREE.Object3D 的实例。
yr {uuid: "6A27DA63-8F99-4E50-9A99-90BED6CE5B85", name: "", type: "Mesh", parent: null, children: Array(0), ...}
castShadow: 假
孩子们:[]
绘制模式:0
frustumCulled:真
几何:Ii {uuid:“8C6C2DD2-B233-4E98-998C-2307A84D1E4B”,名称:“”,类型:“BoxBufferGeometry”,索引:pi,属性:{...},...}
层:Pn {掩码:1}
材质:hc {uuid:“9A6A3601-49F6-4D6E-98E1-21C35BF63D80”,名称:“”,类型:“MeshPhongMaterial”,雾:真,灯:真,...}
矩阵:dn {元素:数组(16)}
矩阵自动更新:真
矩阵世界:dn {元素:数组(16)}
matrixWorldNeedsUpdate:假
名称:“”
父母:空
位置:在 {x: 0, y: -1000, z: -2000}
四元数:Et {_x: 0, _y: 0, _z: 0, _w: 1, onChangeCallback: ƒ}
接收阴影:假
渲染顺序:0
旋转:Cn {_x:0,_y:0,_z:0,_order:“XYZ”,onChangeCallback:ƒ}
比例:在 {x: 1, y: 1, z: 1}
类型:“网格”
向上:在 {x: 0, y: 1, z: 0}
用户数据:{}
uuid:“6A27DA63-8F99-4E50-9A99-90BED6CE5B85”
可见:真
eulerOrder: (...)
编号:3
modelViewMatrix: dn {元素: Array(16)}
normalMatrix: Lt {元素: Array(9)}
useQuaternion: (...)
proto: $n
有什么想法吗??
【问题讨论】:
标签: typescript three.js autodesk-forge autodesk-viewer autodesk