Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/442.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript threejs-未包含在scene.toJSON输出中的网格上的customDepthMaterial属性_Javascript_Three.js - Fatal编程技术网

Javascript threejs-未包含在scene.toJSON输出中的网格上的customDepthMaterial属性

Javascript threejs-未包含在scene.toJSON输出中的网格上的customDepthMaterial属性,javascript,three.js,Javascript,Three.js,我有一个我正在创建的对象,如下所示: const geometry = new THREE.SphereBufferGeometry(2,100,100); const material = new THREE.MeshPhongMaterial({ map: myImage transparent: true, side: THREE.DoubleSide, opacity: 0.8 }); const mesh = new THREE.Mesh(geomet

我有一个我正在创建的对象,如下所示:

const geometry = new THREE.SphereBufferGeometry(2,100,100);
const material = new THREE.MeshPhongMaterial({
    map: myImage
    transparent: true,
    side: THREE.DoubleSide,
    opacity: 0.8
});

const mesh = new THREE.Mesh(geometry, material);
该材质具有一定的透明度,我只希望不透明部分投射阴影,因此我添加:

mesh.customDepthMaterial = new THREE.MeshDepthMaterial({
   depthPacking: THREE.RGBADepthPacking,
   alphaTest: 0.4,
   map: image
});
这在场景中渲染得很好。如果检查场景,则网格上存在customDepthMaterial特性

但是当我执行
scene.toJSON()
时,该属性不包括在网格上(如果我将该JSON加载到场景中,透明度将丢失,因为没有customDepthMaterial)

这是有意的吗?还是虫子?还是我只是做错了什么

这是有意的吗?还是虫子?还是我只是做错了什么

你做的一切都对!问题是
three.js
还不支持
Object3D.customDepthMaterial
Object3D.customDistanceMaterial
的序列化/反序列化

我建议您在GitHub上提交一个功能请求

three.js r122