三个js将对象添加到场景中

时间:2017-06-06 20:31:20

标签: javascript three.js

我正在从网站上找到一个示例,并希望在场景中添加textured cube,并且理想情况下将其放在特定位置。这是我到目前为止所尝试的但它没有出现:

var frametexture = new THREE.ImageUtils.loadTexture( 'https://threejs.org/examples/textures/crate.gif' );
var artwork = new THREE.BoxBufferGeometry( 200, 200, 20 );
var material = new THREE.MeshBasicMaterial( { map: frametexture } );
artframe = new THREE.Mesh( artwork, frametexture );
scene.add( artframe );
artwork.scale( - 1, 1, 1 );

这是我的JSFIDDLE

1 个答案:

答案 0 :(得分:0)

var frametexture = new THREE.ImageUtils.loadTexture( 'https://threejs.org/examples/textures/crate.gif' );

应该是

var frametexture = THREE.ImageUtils.loadTexture( 'https://threejs.org/examples/textures/crate.gif' );

artframe = new THREE.Mesh( artwork, frametexture );

需要

artframe = new THREE.Mesh( artwork, material);