未验证 提交 cd8cfdad 编写于 作者: M Michael Herzog 提交者: GitHub

Merge pull request #17639 from Mugen87/dev38

InstancedMesh: Added support for serialization/deserialization.
......@@ -683,6 +683,14 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
if ( this.isMesh && this.drawMode !== TrianglesDrawMode ) object.drawMode = this.drawMode;
if ( this.isInstancedMesh ) {
object.type = 'InstancedMesh';
object.count = this.count;
object.instanceMatrix = this.instanceMatrix.toJSON();
}
//
function serialize( library, element ) {
......
......@@ -19,9 +19,11 @@ import {
LinearMipmapNearestFilter,
LinearMipmapLinearFilter
} from '../constants.js';
import { BufferAttribute } from '../core/BufferAttribute.js';
import { Color } from '../math/Color.js';
import { Object3D } from '../core/Object3D.js';
import { Group } from '../objects/Group.js';
import { InstancedMesh } from '../objects/InstancedMesh.js';
import { Sprite } from '../objects/Sprite.js';
import { Points } from '../objects/Points.js';
import { Line } from '../objects/Line.js';
......@@ -858,7 +860,17 @@ ObjectLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
}
if ( data.drawMode !== undefined ) object.setDrawMode( data.drawMode );
break;
case 'InstancedMesh':
var geometry = getGeometry( data.geometry );
var material = getMaterial( data.material );
var count = data.count;
var instanceMatrix = data.instanceMatrix;
object = new InstancedMesh( geometry, material, count );
object.instanceMatrix = new BufferAttribute( new Float32Array( instanceMatrix.array ), 16 );
break;
......@@ -949,6 +961,8 @@ ObjectLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
if ( data.userData !== undefined ) object.userData = data.userData;
if ( data.layers !== undefined ) object.layers.mask = data.layers;
if ( data.drawMode !== undefined ) object.setDrawMode( data.drawMode );
if ( data.children !== undefined ) {
var children = data.children;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册