|
@@ -32,90 +32,90 @@ module BABYLON.GLTF2 {
|
|
/**
|
|
/**
|
|
* Stores all generated buffer views, which represents views into the main glTF buffer data
|
|
* Stores all generated buffer views, which represents views into the main glTF buffer data
|
|
*/
|
|
*/
|
|
- private bufferViews: IBufferView[];
|
|
|
|
|
|
+ private _bufferViews: IBufferView[];
|
|
/**
|
|
/**
|
|
* Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
|
|
* Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
|
|
*/
|
|
*/
|
|
- private accessors: IAccessor[];
|
|
|
|
|
|
+ private _accessors: IAccessor[];
|
|
/**
|
|
/**
|
|
* Stores all the generated nodes, which contains transform and/or mesh information per node
|
|
* Stores all the generated nodes, which contains transform and/or mesh information per node
|
|
*/
|
|
*/
|
|
- private nodes: INode[];
|
|
|
|
|
|
+ private _nodes: INode[];
|
|
/**
|
|
/**
|
|
* Stores the glTF asset information, which represents the glTF version and this file generator
|
|
* Stores the glTF asset information, which represents the glTF version and this file generator
|
|
*/
|
|
*/
|
|
- private asset: IAsset;
|
|
|
|
|
|
+ private _asset: IAsset;
|
|
/**
|
|
/**
|
|
* Stores all the generated glTF scenes, which stores multiple node hierarchies
|
|
* Stores all the generated glTF scenes, which stores multiple node hierarchies
|
|
*/
|
|
*/
|
|
- private scenes: IScene[];
|
|
|
|
|
|
+ private _scenes: IScene[];
|
|
/**
|
|
/**
|
|
* Stores all the generated mesh information, each containing a set of primitives to render in glTF
|
|
* Stores all the generated mesh information, each containing a set of primitives to render in glTF
|
|
*/
|
|
*/
|
|
- private meshes: IMesh[];
|
|
|
|
|
|
+ private _meshes: IMesh[];
|
|
/**
|
|
/**
|
|
* Stores all the generated material information, which represents the appearance of each primitive
|
|
* Stores all the generated material information, which represents the appearance of each primitive
|
|
*/
|
|
*/
|
|
- public materials: IMaterial[];
|
|
|
|
|
|
+ public _materials: IMaterial[];
|
|
|
|
|
|
- public materialMap: { [materialID: number]: number };
|
|
|
|
|
|
+ public _materialMap: { [materialID: number]: number };
|
|
/**
|
|
/**
|
|
* Stores all the generated texture information, which is referenced by glTF materials
|
|
* Stores all the generated texture information, which is referenced by glTF materials
|
|
*/
|
|
*/
|
|
- public textures: ITexture[];
|
|
|
|
|
|
+ public _textures: ITexture[];
|
|
/**
|
|
/**
|
|
* Stores all the generated image information, which is referenced by glTF textures
|
|
* Stores all the generated image information, which is referenced by glTF textures
|
|
*/
|
|
*/
|
|
- public images: IImage[];
|
|
|
|
|
|
+ public _images: IImage[];
|
|
|
|
|
|
/**
|
|
/**
|
|
* Stores all the texture samplers
|
|
* Stores all the texture samplers
|
|
*/
|
|
*/
|
|
- public samplers: ISampler[];
|
|
|
|
|
|
+ public _samplers: ISampler[];
|
|
/**
|
|
/**
|
|
* Stores all the generated animation samplers, which is referenced by glTF animations
|
|
* Stores all the generated animation samplers, which is referenced by glTF animations
|
|
*/
|
|
*/
|
|
/**
|
|
/**
|
|
* Stores the animations for glTF models
|
|
* Stores the animations for glTF models
|
|
*/
|
|
*/
|
|
- private animations: IAnimation[];
|
|
|
|
|
|
+ private _animations: IAnimation[];
|
|
/**
|
|
/**
|
|
* Stores the total amount of bytes stored in the glTF buffer
|
|
* Stores the total amount of bytes stored in the glTF buffer
|
|
*/
|
|
*/
|
|
- private totalByteLength: number;
|
|
|
|
|
|
+ private _totalByteLength: number;
|
|
/**
|
|
/**
|
|
* Stores a reference to the Babylon scene containing the source geometry and material information
|
|
* Stores a reference to the Babylon scene containing the source geometry and material information
|
|
*/
|
|
*/
|
|
- private babylonScene: Scene;
|
|
|
|
|
|
+ private _babylonScene: Scene;
|
|
/**
|
|
/**
|
|
* Stores a map of the image data, where the key is the file name and the value
|
|
* Stores a map of the image data, where the key is the file name and the value
|
|
* is the image data
|
|
* is the image data
|
|
*/
|
|
*/
|
|
- public imageData: { [fileName: string]: { data: Uint8Array, mimeType: ImageMimeType } };
|
|
|
|
|
|
+ public _imageData: { [fileName: string]: { data: Uint8Array, mimeType: ImageMimeType } };
|
|
|
|
|
|
/**
|
|
/**
|
|
* Stores a map of the unique id of a node to its index in the node array
|
|
* Stores a map of the unique id of a node to its index in the node array
|
|
*/
|
|
*/
|
|
- private nodeMap: { [key: number]: number };
|
|
|
|
|
|
+ private _nodeMap: { [key: number]: number };
|
|
|
|
|
|
/**
|
|
/**
|
|
* Specifies if the Babylon scene should be converted to right-handed on export
|
|
* Specifies if the Babylon scene should be converted to right-handed on export
|
|
*/
|
|
*/
|
|
- private convertToRightHandedSystem: boolean;
|
|
|
|
|
|
+ private _convertToRightHandedSystem: boolean;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Baked animation sample rate
|
|
* Baked animation sample rate
|
|
*/
|
|
*/
|
|
- private animationSampleRate: number;
|
|
|
|
|
|
+ private _animationSampleRate: number;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Callback which specifies if a transform node should be exported or not
|
|
* Callback which specifies if a transform node should be exported or not
|
|
*/
|
|
*/
|
|
- private shouldExportTransformNode: ((babylonTransformNode: TransformNode) => boolean);
|
|
|
|
|
|
+ private _shouldExportTransformNode: ((babylonTransformNode: TransformNode) => boolean);
|
|
|
|
|
|
public _localEngine: Engine;
|
|
public _localEngine: Engine;
|
|
|
|
|
|
- private _glTFMaterial: _GLTFMaterial;
|
|
|
|
|
|
+ private _glTFMaterialExporter: _GLTFMaterialExporter;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Creates a glTF Exporter instance, which can accept optional exporter options
|
|
* Creates a glTF Exporter instance, which can accept optional exporter options
|
|
@@ -123,31 +123,32 @@ module BABYLON.GLTF2 {
|
|
* @param options Options to modify the behavior of the exporter
|
|
* @param options Options to modify the behavior of the exporter
|
|
*/
|
|
*/
|
|
public constructor(babylonScene: Scene, options?: IExportOptions) {
|
|
public constructor(babylonScene: Scene, options?: IExportOptions) {
|
|
- this.asset = { generator: "BabylonJS", version: "2.0" };
|
|
|
|
- this.babylonScene = babylonScene;
|
|
|
|
- this.bufferViews = [];
|
|
|
|
- this.accessors = [];
|
|
|
|
- this.meshes = [];
|
|
|
|
- this.scenes = [];
|
|
|
|
- this.nodes = [];
|
|
|
|
- this.images = [];
|
|
|
|
- this.materials = [];
|
|
|
|
- this.materialMap = [];
|
|
|
|
- this.textures = [];
|
|
|
|
- this.samplers = [];
|
|
|
|
- this.animations = [];
|
|
|
|
- this.imageData = {};
|
|
|
|
- this.convertToRightHandedSystem = this.babylonScene.useRightHandedSystem ? false : true;
|
|
|
|
|
|
+ this._asset = { generator: "BabylonJS", version: "2.0" };
|
|
|
|
+ this._babylonScene = babylonScene;
|
|
|
|
+ this._bufferViews = [];
|
|
|
|
+ this._accessors = [];
|
|
|
|
+ this._meshes = [];
|
|
|
|
+ this._scenes = [];
|
|
|
|
+ this._nodes = [];
|
|
|
|
+ this._images = [];
|
|
|
|
+ this._materials = [];
|
|
|
|
+ this._materialMap = [];
|
|
|
|
+ this._textures = [];
|
|
|
|
+ this._samplers = [];
|
|
|
|
+ this._animations = [];
|
|
|
|
+ this._imageData = {};
|
|
|
|
+ this._convertToRightHandedSystem = this._babylonScene.useRightHandedSystem ? false : true;
|
|
const _options = options || {};
|
|
const _options = options || {};
|
|
- this.shouldExportTransformNode = _options.shouldExportTransformNode ? _options.shouldExportTransformNode : (babylonTransformNode: TransformNode) => true;
|
|
|
|
- this.animationSampleRate = _options.animationSampleRate ? _options.animationSampleRate : 1 / 60;
|
|
|
|
|
|
+ this._shouldExportTransformNode = _options.shouldExportTransformNode ? _options.shouldExportTransformNode : (babylonTransformNode: TransformNode) => true;
|
|
|
|
+ this._animationSampleRate = _options.animationSampleRate ? _options.animationSampleRate : 1 / 60;
|
|
|
|
|
|
const localCanvas = document.createElement('canvas');
|
|
const localCanvas = document.createElement('canvas');
|
|
localCanvas.id = "WriteCanvas";
|
|
localCanvas.id = "WriteCanvas";
|
|
localCanvas.width = 2048;
|
|
localCanvas.width = 2048;
|
|
localCanvas.height = 2048;
|
|
localCanvas.height = 2048;
|
|
this._localEngine = new Engine(localCanvas, true, { premultipliedAlpha: false, preserveDrawingBuffer: true });
|
|
this._localEngine = new Engine(localCanvas, true, { premultipliedAlpha: false, preserveDrawingBuffer: true });
|
|
- this._glTFMaterial = new _GLTFMaterial(this);
|
|
|
|
|
|
+ this._localEngine.setViewport(new Viewport(0,0,1,1));
|
|
|
|
+ this._glTFMaterialExporter = new _GLTFMaterialExporter(this);
|
|
}
|
|
}
|
|
|
|
|
|
private reorderIndicesBasedOnPrimitiveMode(submesh: SubMesh, primitiveMode: number, babylonIndices: IndicesArray, byteOffset: number, binaryWriter: _BinaryWriter) {
|
|
private reorderIndicesBasedOnPrimitiveMode(submesh: SubMesh, primitiveMode: number, babylonIndices: IndicesArray, byteOffset: number, binaryWriter: _BinaryWriter) {
|
|
@@ -193,7 +194,7 @@ module BABYLON.GLTF2 {
|
|
* @param binaryWriter The binary data for the glTF file
|
|
* @param binaryWriter The binary data for the glTF file
|
|
*/
|
|
*/
|
|
private reorderVertexAttributeDataBasedOnPrimitiveMode(submesh: SubMesh, primitiveMode: number, sideOrientation: number, vertexBufferKind: string, meshAttributeArray: FloatArray, byteOffset: number, binaryWriter: _BinaryWriter): void {
|
|
private reorderVertexAttributeDataBasedOnPrimitiveMode(submesh: SubMesh, primitiveMode: number, sideOrientation: number, vertexBufferKind: string, meshAttributeArray: FloatArray, byteOffset: number, binaryWriter: _BinaryWriter): void {
|
|
- if (this.convertToRightHandedSystem && sideOrientation === Material.ClockWiseSideOrientation) {
|
|
|
|
|
|
+ if (this._convertToRightHandedSystem && sideOrientation === Material.ClockWiseSideOrientation) {
|
|
switch (primitiveMode) {
|
|
switch (primitiveMode) {
|
|
case Material.TriangleFillMode: {
|
|
case Material.TriangleFillMode: {
|
|
this.reorderTriangleFillMode(submesh, primitiveMode, sideOrientation, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter);
|
|
this.reorderTriangleFillMode(submesh, primitiveMode, sideOrientation, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter);
|
|
@@ -423,7 +424,7 @@ module BABYLON.GLTF2 {
|
|
*/
|
|
*/
|
|
private writeVertexAttributeData(vertices: Vector2[] | Vector3[] | Vector4[], byteOffset: number, vertexAttributeKind: string, meshAttributeArray: FloatArray, binaryWriter: _BinaryWriter) {
|
|
private writeVertexAttributeData(vertices: Vector2[] | Vector3[] | Vector4[], byteOffset: number, vertexAttributeKind: string, meshAttributeArray: FloatArray, binaryWriter: _BinaryWriter) {
|
|
for (let vertex of vertices) {
|
|
for (let vertex of vertices) {
|
|
- if (this.convertToRightHandedSystem && !(vertexAttributeKind === VertexBuffer.ColorKind) && !(vertex instanceof Vector2)) {
|
|
|
|
|
|
+ if (this._convertToRightHandedSystem && !(vertexAttributeKind === VertexBuffer.ColorKind) && !(vertex instanceof Vector2)) {
|
|
if (vertex instanceof Vector3) {
|
|
if (vertex instanceof Vector3) {
|
|
(vertexAttributeKind === VertexBuffer.PositionKind) ? _GLTFUtilities.GetRightHandedPositionVector3FromRef(vertex) : _GLTFUtilities.GetRightHandedNormalVector3FromRef(vertex);
|
|
(vertexAttributeKind === VertexBuffer.PositionKind) ? _GLTFUtilities.GetRightHandedPositionVector3FromRef(vertex) : _GLTFUtilities.GetRightHandedNormalVector3FromRef(vertex);
|
|
}
|
|
}
|
|
@@ -456,7 +457,7 @@ module BABYLON.GLTF2 {
|
|
for (let k = 0, length = meshAttributeArray.length / stride; k < length; ++k) {
|
|
for (let k = 0, length = meshAttributeArray.length / stride; k < length; ++k) {
|
|
index = k * stride;
|
|
index = k * stride;
|
|
const vertexData = Vector3.FromArray(meshAttributeArray, index);
|
|
const vertexData = Vector3.FromArray(meshAttributeArray, index);
|
|
- if (this.convertToRightHandedSystem) {
|
|
|
|
|
|
+ if (this._convertToRightHandedSystem) {
|
|
_GLTFUtilities.GetRightHandedPositionVector3FromRef(vertexData);
|
|
_GLTFUtilities.GetRightHandedPositionVector3FromRef(vertexData);
|
|
}
|
|
}
|
|
vertexAttributes.push(vertexData.asArray());
|
|
vertexAttributes.push(vertexData.asArray());
|
|
@@ -467,7 +468,7 @@ module BABYLON.GLTF2 {
|
|
for (let k = 0, length = meshAttributeArray.length / stride; k < length; ++k) {
|
|
for (let k = 0, length = meshAttributeArray.length / stride; k < length; ++k) {
|
|
index = k * stride;
|
|
index = k * stride;
|
|
const vertexData = Vector3.FromArray(meshAttributeArray, index);
|
|
const vertexData = Vector3.FromArray(meshAttributeArray, index);
|
|
- if (this.convertToRightHandedSystem) {
|
|
|
|
|
|
+ if (this._convertToRightHandedSystem) {
|
|
_GLTFUtilities.GetRightHandedNormalVector3FromRef(vertexData);
|
|
_GLTFUtilities.GetRightHandedNormalVector3FromRef(vertexData);
|
|
}
|
|
}
|
|
vertexAttributes.push(vertexData.asArray());
|
|
vertexAttributes.push(vertexData.asArray());
|
|
@@ -478,7 +479,7 @@ module BABYLON.GLTF2 {
|
|
for (let k = 0, length = meshAttributeArray.length / stride; k < length; ++k) {
|
|
for (let k = 0, length = meshAttributeArray.length / stride; k < length; ++k) {
|
|
index = k * stride;
|
|
index = k * stride;
|
|
const vertexData = Vector4.FromArray(meshAttributeArray, index);
|
|
const vertexData = Vector4.FromArray(meshAttributeArray, index);
|
|
- if (this.convertToRightHandedSystem) {
|
|
|
|
|
|
+ if (this._convertToRightHandedSystem) {
|
|
_GLTFUtilities.GetRightHandedVector4FromRef(vertexData);
|
|
_GLTFUtilities.GetRightHandedVector4FromRef(vertexData);
|
|
}
|
|
}
|
|
vertexAttributes.push(vertexData.asArray());
|
|
vertexAttributes.push(vertexData.asArray());
|
|
@@ -497,7 +498,7 @@ module BABYLON.GLTF2 {
|
|
case VertexBuffer.UV2Kind: {
|
|
case VertexBuffer.UV2Kind: {
|
|
for (let k = 0, length = meshAttributeArray.length / stride; k < length; ++k) {
|
|
for (let k = 0, length = meshAttributeArray.length / stride; k < length; ++k) {
|
|
index = k * stride;
|
|
index = k * stride;
|
|
- vertexAttributes.push(this.convertToRightHandedSystem ? [meshAttributeArray[index], meshAttributeArray[index + 1]] : [meshAttributeArray[index], meshAttributeArray[index + 1]]);
|
|
|
|
|
|
+ vertexAttributes.push(this._convertToRightHandedSystem ? [meshAttributeArray[index], meshAttributeArray[index + 1]] : [meshAttributeArray[index], meshAttributeArray[index + 1]]);
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -521,61 +522,61 @@ module BABYLON.GLTF2 {
|
|
* @returns json data as string
|
|
* @returns json data as string
|
|
*/
|
|
*/
|
|
private generateJSON(shouldUseGlb: boolean, glTFPrefix?: string, prettyPrint?: boolean): string {
|
|
private generateJSON(shouldUseGlb: boolean, glTFPrefix?: string, prettyPrint?: boolean): string {
|
|
- let buffer: IBuffer = { byteLength: this.totalByteLength };
|
|
|
|
|
|
+ let buffer: IBuffer = { byteLength: this._totalByteLength };
|
|
let imageName: string;
|
|
let imageName: string;
|
|
let imageData: { data: Uint8Array, mimeType: ImageMimeType };
|
|
let imageData: { data: Uint8Array, mimeType: ImageMimeType };
|
|
let bufferView: IBufferView;
|
|
let bufferView: IBufferView;
|
|
- let byteOffset: number = this.totalByteLength;
|
|
|
|
|
|
+ let byteOffset: number = this._totalByteLength;
|
|
|
|
|
|
let glTF: IGLTF = {
|
|
let glTF: IGLTF = {
|
|
- asset: this.asset
|
|
|
|
|
|
+ asset: this._asset
|
|
};
|
|
};
|
|
if (buffer.byteLength) {
|
|
if (buffer.byteLength) {
|
|
glTF.buffers = [buffer];
|
|
glTF.buffers = [buffer];
|
|
}
|
|
}
|
|
- if (this.nodes && this.nodes.length) {
|
|
|
|
- glTF.nodes = this.nodes;
|
|
|
|
|
|
+ if (this._nodes && this._nodes.length) {
|
|
|
|
+ glTF.nodes = this._nodes;
|
|
}
|
|
}
|
|
- if (this.meshes && this.meshes.length) {
|
|
|
|
- glTF.meshes = this.meshes;
|
|
|
|
|
|
+ if (this._meshes && this._meshes.length) {
|
|
|
|
+ glTF.meshes = this._meshes;
|
|
}
|
|
}
|
|
- if (this.scenes && this.scenes.length) {
|
|
|
|
- glTF.scenes = this.scenes;
|
|
|
|
|
|
+ if (this._scenes && this._scenes.length) {
|
|
|
|
+ glTF.scenes = this._scenes;
|
|
glTF.scene = 0;
|
|
glTF.scene = 0;
|
|
}
|
|
}
|
|
- if (this.bufferViews && this.bufferViews.length) {
|
|
|
|
- glTF.bufferViews = this.bufferViews;
|
|
|
|
|
|
+ if (this._bufferViews && this._bufferViews.length) {
|
|
|
|
+ glTF.bufferViews = this._bufferViews;
|
|
}
|
|
}
|
|
- if (this.accessors && this.accessors.length) {
|
|
|
|
- glTF.accessors = this.accessors;
|
|
|
|
|
|
+ if (this._accessors && this._accessors.length) {
|
|
|
|
+ glTF.accessors = this._accessors;
|
|
}
|
|
}
|
|
- if (this.animations && this.animations.length) {
|
|
|
|
- glTF.animations = this.animations;
|
|
|
|
|
|
+ if (this._animations && this._animations.length) {
|
|
|
|
+ glTF.animations = this._animations;
|
|
}
|
|
}
|
|
- if (this.materials && this.materials.length) {
|
|
|
|
- glTF.materials = this.materials;
|
|
|
|
|
|
+ if (this._materials && this._materials.length) {
|
|
|
|
+ glTF.materials = this._materials;
|
|
}
|
|
}
|
|
- if (this.textures && this.textures.length) {
|
|
|
|
- glTF.textures = this.textures;
|
|
|
|
|
|
+ if (this._textures && this._textures.length) {
|
|
|
|
+ glTF.textures = this._textures;
|
|
}
|
|
}
|
|
- if (this.samplers && this.samplers.length) {
|
|
|
|
- glTF.samplers = this.samplers;
|
|
|
|
|
|
+ if (this._samplers && this._samplers.length) {
|
|
|
|
+ glTF.samplers = this._samplers;
|
|
}
|
|
}
|
|
- if (this.images && this.images.length) {
|
|
|
|
|
|
+ if (this._images && this._images.length) {
|
|
if (!shouldUseGlb) {
|
|
if (!shouldUseGlb) {
|
|
- glTF.images = this.images;
|
|
|
|
|
|
+ glTF.images = this._images;
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
glTF.images = [];
|
|
glTF.images = [];
|
|
|
|
|
|
- this.images.forEach((image) => {
|
|
|
|
|
|
+ this._images.forEach((image) => {
|
|
if (image.uri) {
|
|
if (image.uri) {
|
|
- imageData = this.imageData[image.uri];
|
|
|
|
|
|
+ imageData = this._imageData[image.uri];
|
|
imageName = image.uri.split('.')[0] + " image";
|
|
imageName = image.uri.split('.')[0] + " image";
|
|
bufferView = _GLTFUtilities.CreateBufferView(0, byteOffset, imageData.data.length, undefined, imageName);
|
|
bufferView = _GLTFUtilities.CreateBufferView(0, byteOffset, imageData.data.length, undefined, imageName);
|
|
byteOffset += imageData.data.buffer.byteLength;
|
|
byteOffset += imageData.data.buffer.byteLength;
|
|
- this.bufferViews.push(bufferView);
|
|
|
|
- image.bufferView = this.bufferViews.length - 1;
|
|
|
|
|
|
+ this._bufferViews.push(bufferView);
|
|
|
|
+ image.bufferView = this._bufferViews.length - 1;
|
|
image.name = imageName;
|
|
image.name = imageName;
|
|
image.mimeType = imageData.mimeType;
|
|
image.mimeType = imageData.mimeType;
|
|
image.uri = undefined;
|
|
image.uri = undefined;
|
|
@@ -617,9 +618,9 @@ module BABYLON.GLTF2 {
|
|
container.glTFFiles[glTFFileName] = jsonText;
|
|
container.glTFFiles[glTFFileName] = jsonText;
|
|
container.glTFFiles[glTFBinFile] = bin;
|
|
container.glTFFiles[glTFBinFile] = bin;
|
|
|
|
|
|
- if (this.imageData) {
|
|
|
|
- for (let image in this.imageData) {
|
|
|
|
- container.glTFFiles[image] = new Blob([this.imageData[image].data], { type: this.imageData[image].mimeType });
|
|
|
|
|
|
+ if (this._imageData) {
|
|
|
|
+ for (let image in this._imageData) {
|
|
|
|
+ container.glTFFiles[image] = new Blob([this._imageData[image].data], { type: this._imageData[image].mimeType });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -634,7 +635,7 @@ module BABYLON.GLTF2 {
|
|
*/
|
|
*/
|
|
private _generateBinaryAsync(): Promise<ArrayBuffer> {
|
|
private _generateBinaryAsync(): Promise<ArrayBuffer> {
|
|
let binaryWriter = new _BinaryWriter(4);
|
|
let binaryWriter = new _BinaryWriter(4);
|
|
- return this.createSceneAsync(this.babylonScene, binaryWriter).then(() => {
|
|
|
|
|
|
+ return this.createSceneAsync(this._babylonScene, binaryWriter).then(() => {
|
|
return binaryWriter.getArrayBuffer();
|
|
return binaryWriter.getArrayBuffer();
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -666,8 +667,8 @@ module BABYLON.GLTF2 {
|
|
const jsonLength = jsonText.length;
|
|
const jsonLength = jsonText.length;
|
|
let imageByteLength = 0;
|
|
let imageByteLength = 0;
|
|
|
|
|
|
- for (let key in this.imageData) {
|
|
|
|
- imageByteLength += this.imageData[key].data.byteLength;
|
|
|
|
|
|
+ for (let key in this._imageData) {
|
|
|
|
+ imageByteLength += this._imageData[key].data.byteLength;
|
|
}
|
|
}
|
|
const jsonPadding = this._getPadding(jsonLength);
|
|
const jsonPadding = this._getPadding(jsonLength);
|
|
const binPadding = this._getPadding(binaryBuffer.byteLength);
|
|
const binPadding = this._getPadding(binaryBuffer.byteLength);
|
|
@@ -722,8 +723,8 @@ module BABYLON.GLTF2 {
|
|
const glbData = [headerBuffer, jsonChunkBuffer, binaryChunkBuffer, binaryBuffer];
|
|
const glbData = [headerBuffer, jsonChunkBuffer, binaryChunkBuffer, binaryBuffer];
|
|
|
|
|
|
// binary data
|
|
// binary data
|
|
- for (let key in this.imageData) {
|
|
|
|
- glbData.push(this.imageData[key].data.buffer);
|
|
|
|
|
|
+ for (let key in this._imageData) {
|
|
|
|
+ glbData.push(this._imageData[key].data.buffer);
|
|
}
|
|
}
|
|
glbData.push(binPaddingBuffer);
|
|
glbData.push(binPaddingBuffer);
|
|
|
|
|
|
@@ -747,7 +748,7 @@ module BABYLON.GLTF2 {
|
|
*/
|
|
*/
|
|
private setNodeTransformation(node: INode, babylonTransformNode: TransformNode): void {
|
|
private setNodeTransformation(node: INode, babylonTransformNode: TransformNode): void {
|
|
if (!babylonTransformNode.position.equalsToFloats(0, 0, 0)) {
|
|
if (!babylonTransformNode.position.equalsToFloats(0, 0, 0)) {
|
|
- node.translation = this.convertToRightHandedSystem ? _GLTFUtilities.GetRightHandedPositionVector3(babylonTransformNode.position).asArray() : babylonTransformNode.position.asArray();
|
|
|
|
|
|
+ node.translation = this._convertToRightHandedSystem ? _GLTFUtilities.GetRightHandedPositionVector3(babylonTransformNode.position).asArray() : babylonTransformNode.position.asArray();
|
|
}
|
|
}
|
|
|
|
|
|
if (!babylonTransformNode.scaling.equalsToFloats(1, 1, 1)) {
|
|
if (!babylonTransformNode.scaling.equalsToFloats(1, 1, 1)) {
|
|
@@ -759,7 +760,7 @@ module BABYLON.GLTF2 {
|
|
rotationQuaternion.multiplyInPlace(babylonTransformNode.rotationQuaternion);
|
|
rotationQuaternion.multiplyInPlace(babylonTransformNode.rotationQuaternion);
|
|
}
|
|
}
|
|
if (!(rotationQuaternion.x === 0 && rotationQuaternion.y === 0 && rotationQuaternion.z === 0 && rotationQuaternion.w === 1)) {
|
|
if (!(rotationQuaternion.x === 0 && rotationQuaternion.y === 0 && rotationQuaternion.z === 0 && rotationQuaternion.w === 1)) {
|
|
- if (this.convertToRightHandedSystem) {
|
|
|
|
|
|
+ if (this._convertToRightHandedSystem) {
|
|
_GLTFUtilities.GetRightHandedQuaternionFromRef(rotationQuaternion);
|
|
_GLTFUtilities.GetRightHandedQuaternionFromRef(rotationQuaternion);
|
|
|
|
|
|
}
|
|
}
|
|
@@ -794,7 +795,7 @@ module BABYLON.GLTF2 {
|
|
if (vertexData) {
|
|
if (vertexData) {
|
|
const byteLength = vertexData.length * 4;
|
|
const byteLength = vertexData.length * 4;
|
|
const bufferView = _GLTFUtilities.CreateBufferView(0, binaryWriter.getByteOffset(), byteLength, byteStride, kind + " - " + bufferMesh.name);
|
|
const bufferView = _GLTFUtilities.CreateBufferView(0, binaryWriter.getByteOffset(), byteLength, byteStride, kind + " - " + bufferMesh.name);
|
|
- this.bufferViews.push(bufferView);
|
|
|
|
|
|
+ this._bufferViews.push(bufferView);
|
|
|
|
|
|
this.writeAttributeData(
|
|
this.writeAttributeData(
|
|
kind,
|
|
kind,
|
|
@@ -867,27 +868,27 @@ module BABYLON.GLTF2 {
|
|
private setAttributeKind(meshPrimitive: IMeshPrimitive, attributeKind: string): void {
|
|
private setAttributeKind(meshPrimitive: IMeshPrimitive, attributeKind: string): void {
|
|
switch (attributeKind) {
|
|
switch (attributeKind) {
|
|
case VertexBuffer.PositionKind: {
|
|
case VertexBuffer.PositionKind: {
|
|
- meshPrimitive.attributes.POSITION = this.accessors.length - 1;
|
|
|
|
|
|
+ meshPrimitive.attributes.POSITION = this._accessors.length - 1;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
case VertexBuffer.NormalKind: {
|
|
case VertexBuffer.NormalKind: {
|
|
- meshPrimitive.attributes.NORMAL = this.accessors.length - 1;
|
|
|
|
|
|
+ meshPrimitive.attributes.NORMAL = this._accessors.length - 1;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
case VertexBuffer.ColorKind: {
|
|
case VertexBuffer.ColorKind: {
|
|
- meshPrimitive.attributes.COLOR_0 = this.accessors.length - 1;
|
|
|
|
|
|
+ meshPrimitive.attributes.COLOR_0 = this._accessors.length - 1;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
case VertexBuffer.TangentKind: {
|
|
case VertexBuffer.TangentKind: {
|
|
- meshPrimitive.attributes.TANGENT = this.accessors.length - 1;
|
|
|
|
|
|
+ meshPrimitive.attributes.TANGENT = this._accessors.length - 1;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
case VertexBuffer.UVKind: {
|
|
case VertexBuffer.UVKind: {
|
|
- meshPrimitive.attributes.TEXCOORD_0 = this.accessors.length - 1;
|
|
|
|
|
|
+ meshPrimitive.attributes.TEXCOORD_0 = this._accessors.length - 1;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
case VertexBuffer.UV2Kind: {
|
|
case VertexBuffer.UV2Kind: {
|
|
- meshPrimitive.attributes.TEXCOORD_1 = this.accessors.length - 1;
|
|
|
|
|
|
+ meshPrimitive.attributes.TEXCOORD_1 = this._accessors.length - 1;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
default: {
|
|
default: {
|
|
@@ -939,7 +940,7 @@ module BABYLON.GLTF2 {
|
|
}
|
|
}
|
|
|
|
|
|
this.createBufferViewKind(attributeKind, babylonTransformNode, binaryWriter, attribute.byteStride);
|
|
this.createBufferViewKind(attributeKind, babylonTransformNode, binaryWriter, attribute.byteStride);
|
|
- attribute.bufferViewIndex = this.bufferViews.length - 1;
|
|
|
|
|
|
+ attribute.bufferViewIndex = this._bufferViews.length - 1;
|
|
vertexAttributeBufferViews[attributeKind] = attribute.bufferViewIndex;
|
|
vertexAttributeBufferViews[attributeKind] = attribute.bufferViewIndex;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -949,8 +950,8 @@ module BABYLON.GLTF2 {
|
|
if (indices) {
|
|
if (indices) {
|
|
const byteLength = indices.length * 4;
|
|
const byteLength = indices.length * 4;
|
|
bufferView = _GLTFUtilities.CreateBufferView(0, binaryWriter.getByteOffset(), byteLength, undefined, "Indices - " + bufferMesh.name);
|
|
bufferView = _GLTFUtilities.CreateBufferView(0, binaryWriter.getByteOffset(), byteLength, undefined, "Indices - " + bufferMesh.name);
|
|
- this.bufferViews.push(bufferView);
|
|
|
|
- indexBufferViewIndex = this.bufferViews.length - 1;
|
|
|
|
|
|
+ this._bufferViews.push(bufferView);
|
|
|
|
+ indexBufferViewIndex = this._bufferViews.length - 1;
|
|
|
|
|
|
for (let k = 0, length = indices.length; k < length; ++k) {
|
|
for (let k = 0, length = indices.length; k < length; ++k) {
|
|
binaryWriter.setUInt32(indices[k]);
|
|
binaryWriter.setUInt32(indices[k]);
|
|
@@ -976,21 +977,21 @@ module BABYLON.GLTF2 {
|
|
baseColorFactor: bufferMesh.color.asArray().concat([bufferMesh.alpha])
|
|
baseColorFactor: bufferMesh.color.asArray().concat([bufferMesh.alpha])
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- this.materials.push(material);
|
|
|
|
- materialIndex = this.materials.length - 1;
|
|
|
|
|
|
+ this._materials.push(material);
|
|
|
|
+ materialIndex = this._materials.length - 1;
|
|
}
|
|
}
|
|
else if (babylonMaterial instanceof MultiMaterial) {
|
|
else if (babylonMaterial instanceof MultiMaterial) {
|
|
babylonMaterial = babylonMaterial.subMaterials[submesh.materialIndex];
|
|
babylonMaterial = babylonMaterial.subMaterials[submesh.materialIndex];
|
|
if (babylonMaterial) {
|
|
if (babylonMaterial) {
|
|
- materialIndex = this.materialMap[babylonMaterial.uniqueId];
|
|
|
|
|
|
+ materialIndex = this._materialMap[babylonMaterial.uniqueId];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- materialIndex = this.materialMap[babylonMaterial.uniqueId];
|
|
|
|
|
|
+ materialIndex = this._materialMap[babylonMaterial.uniqueId];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- let glTFMaterial: Nullable<IMaterial> = materialIndex != null ? this.materials[materialIndex] : null;
|
|
|
|
|
|
+ let glTFMaterial: Nullable<IMaterial> = materialIndex != null ? this._materials[materialIndex] : null;
|
|
|
|
|
|
const meshPrimitive: IMeshPrimitive = { attributes: {} };
|
|
const meshPrimitive: IMeshPrimitive = { attributes: {} };
|
|
this.setPrimitiveMode(meshPrimitive, primitiveMode);
|
|
this.setPrimitiveMode(meshPrimitive, primitiveMode);
|
|
@@ -998,7 +999,7 @@ module BABYLON.GLTF2 {
|
|
for (const attribute of attributeData) {
|
|
for (const attribute of attributeData) {
|
|
const attributeKind = attribute.kind;
|
|
const attributeKind = attribute.kind;
|
|
if (attributeKind === VertexBuffer.UVKind || attributeKind === VertexBuffer.UV2Kind) {
|
|
if (attributeKind === VertexBuffer.UVKind || attributeKind === VertexBuffer.UV2Kind) {
|
|
- if (glTFMaterial && !this._glTFMaterial._hasTexturesPresent(glTFMaterial)) {
|
|
|
|
|
|
+ if (glTFMaterial && !this._glTFMaterialExporter._hasTexturesPresent(glTFMaterial)) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1011,10 +1012,10 @@ module BABYLON.GLTF2 {
|
|
if (bufferViewIndex != undefined) { // check to see if bufferviewindex has a numeric value assigned.
|
|
if (bufferViewIndex != undefined) { // check to see if bufferviewindex has a numeric value assigned.
|
|
minMax = { min: null, max: null };
|
|
minMax = { min: null, max: null };
|
|
if (attributeKind == VertexBuffer.PositionKind) {
|
|
if (attributeKind == VertexBuffer.PositionKind) {
|
|
- minMax = _GLTFUtilities.CalculateMinMaxPositions(vertexData, 0, vertexData.length / stride, this.convertToRightHandedSystem);
|
|
|
|
|
|
+ minMax = _GLTFUtilities.CalculateMinMaxPositions(vertexData, 0, vertexData.length / stride, this._convertToRightHandedSystem);
|
|
}
|
|
}
|
|
const accessor = _GLTFUtilities.CreateAccessor(bufferViewIndex, attributeKind + " - " + babylonTransformNode.name, attribute.accessorType, AccessorComponentType.FLOAT, vertexData.length / stride, 0, minMax.min, minMax.max);
|
|
const accessor = _GLTFUtilities.CreateAccessor(bufferViewIndex, attributeKind + " - " + babylonTransformNode.name, attribute.accessorType, AccessorComponentType.FLOAT, vertexData.length / stride, 0, minMax.min, minMax.max);
|
|
- this.accessors.push(accessor);
|
|
|
|
|
|
+ this._accessors.push(accessor);
|
|
this.setAttributeKind(meshPrimitive, attributeKind);
|
|
this.setAttributeKind(meshPrimitive, attributeKind);
|
|
if (meshPrimitive.attributes.TEXCOORD_0 != null || meshPrimitive.attributes.TEXCOORD_1 != null) {
|
|
if (meshPrimitive.attributes.TEXCOORD_0 != null || meshPrimitive.attributes.TEXCOORD_1 != null) {
|
|
uvCoordsPresent = true;
|
|
uvCoordsPresent = true;
|
|
@@ -1026,15 +1027,15 @@ module BABYLON.GLTF2 {
|
|
if (indexBufferViewIndex) {
|
|
if (indexBufferViewIndex) {
|
|
// Create accessor
|
|
// Create accessor
|
|
const accessor = _GLTFUtilities.CreateAccessor(indexBufferViewIndex, "indices - " + babylonTransformNode.name, AccessorType.SCALAR, AccessorComponentType.UNSIGNED_INT, submesh.indexCount, submesh.indexStart * 4, null, null);
|
|
const accessor = _GLTFUtilities.CreateAccessor(indexBufferViewIndex, "indices - " + babylonTransformNode.name, AccessorType.SCALAR, AccessorComponentType.UNSIGNED_INT, submesh.indexCount, submesh.indexStart * 4, null, null);
|
|
- this.accessors.push(accessor);
|
|
|
|
- meshPrimitive.indices = this.accessors.length - 1;
|
|
|
|
|
|
+ this._accessors.push(accessor);
|
|
|
|
+ meshPrimitive.indices = this._accessors.length - 1;
|
|
}
|
|
}
|
|
if (materialIndex != null && Object.keys(meshPrimitive.attributes).length > 0) {
|
|
if (materialIndex != null && Object.keys(meshPrimitive.attributes).length > 0) {
|
|
- let sideOrientation = this.babylonScene.materials[materialIndex].sideOrientation;
|
|
|
|
|
|
+ let sideOrientation = this._babylonScene.materials[materialIndex].sideOrientation;
|
|
|
|
|
|
- if (this.convertToRightHandedSystem && sideOrientation === Material.ClockWiseSideOrientation) {
|
|
|
|
|
|
+ if (this._convertToRightHandedSystem && sideOrientation === Material.ClockWiseSideOrientation) {
|
|
//Overwrite the indices to be counter-clockwise
|
|
//Overwrite the indices to be counter-clockwise
|
|
- let byteOffset = indexBufferViewIndex != null ? this.bufferViews[indexBufferViewIndex].byteOffset : null;
|
|
|
|
|
|
+ let byteOffset = indexBufferViewIndex != null ? this._bufferViews[indexBufferViewIndex].byteOffset : null;
|
|
if (byteOffset == null) { byteOffset = 0; }
|
|
if (byteOffset == null) { byteOffset = 0; }
|
|
let babylonIndices: Nullable<IndicesArray> = null;
|
|
let babylonIndices: Nullable<IndicesArray> = null;
|
|
if (indexBufferViewIndex != null) {
|
|
if (indexBufferViewIndex != null) {
|
|
@@ -1047,7 +1048,7 @@ module BABYLON.GLTF2 {
|
|
for (let attribute of attributeData) {
|
|
for (let attribute of attributeData) {
|
|
let vertexData = bufferMesh.getVerticesData(attribute.kind);
|
|
let vertexData = bufferMesh.getVerticesData(attribute.kind);
|
|
if (vertexData) {
|
|
if (vertexData) {
|
|
- let byteOffset = this.bufferViews[vertexAttributeBufferViews[attribute.kind]].byteOffset;
|
|
|
|
|
|
+ let byteOffset = this._bufferViews[vertexAttributeBufferViews[attribute.kind]].byteOffset;
|
|
if (!byteOffset) {
|
|
if (!byteOffset) {
|
|
byteOffset = 0
|
|
byteOffset = 0
|
|
}
|
|
}
|
|
@@ -1057,10 +1058,10 @@ module BABYLON.GLTF2 {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if (!uvCoordsPresent && this._glTFMaterial._hasTexturesPresent(this.materials[materialIndex])) {
|
|
|
|
- const newMat = this._glTFMaterial._stripTexturesFromMaterial(this.materials[materialIndex]);
|
|
|
|
- this.materials.push(newMat);
|
|
|
|
- materialIndex = this.materials.length - 1;
|
|
|
|
|
|
+ if (!uvCoordsPresent && this._glTFMaterialExporter._hasTexturesPresent(this._materials[materialIndex])) {
|
|
|
|
+ const newMat = this._glTFMaterialExporter._stripTexturesFromMaterial(this._materials[materialIndex]);
|
|
|
|
+ this._materials.push(newMat);
|
|
|
|
+ materialIndex = this._materials.length - 1;
|
|
}
|
|
}
|
|
|
|
|
|
meshPrimitive.material = materialIndex;
|
|
meshPrimitive.material = materialIndex;
|
|
@@ -1085,23 +1086,23 @@ module BABYLON.GLTF2 {
|
|
let directDescendents: Node[];
|
|
let directDescendents: Node[];
|
|
const nodes = [...babylonScene.transformNodes, ...babylonScene.meshes];
|
|
const nodes = [...babylonScene.transformNodes, ...babylonScene.meshes];
|
|
|
|
|
|
- return this._glTFMaterial._convertMaterialsToGLTFAsync(babylonScene.materials, ImageMimeType.PNG, true).then(() => {
|
|
|
|
- this.nodeMap = this.createNodeMapAndAnimations(babylonScene, nodes, this.shouldExportTransformNode, binaryWriter);
|
|
|
|
|
|
+ return this._glTFMaterialExporter._convertMaterialsToGLTFAsync(babylonScene.materials, ImageMimeType.PNG, true).then(() => {
|
|
|
|
+ this._nodeMap = this.createNodeMapAndAnimations(babylonScene, nodes, this._shouldExportTransformNode, binaryWriter);
|
|
|
|
|
|
- this.totalByteLength = binaryWriter.getByteOffset();
|
|
|
|
|
|
+ this._totalByteLength = binaryWriter.getByteOffset();
|
|
|
|
|
|
|
|
|
|
// Build Hierarchy with the node map.
|
|
// Build Hierarchy with the node map.
|
|
for (let babylonTransformNode of nodes) {
|
|
for (let babylonTransformNode of nodes) {
|
|
- glTFNodeIndex = this.nodeMap[babylonTransformNode.uniqueId];
|
|
|
|
|
|
+ glTFNodeIndex = this._nodeMap[babylonTransformNode.uniqueId];
|
|
if (glTFNodeIndex != null) {
|
|
if (glTFNodeIndex != null) {
|
|
- glTFNode = this.nodes[glTFNodeIndex];
|
|
|
|
|
|
+ glTFNode = this._nodes[glTFNodeIndex];
|
|
if (!babylonTransformNode.parent) {
|
|
if (!babylonTransformNode.parent) {
|
|
- if (!this.shouldExportTransformNode(babylonTransformNode)) {
|
|
|
|
|
|
+ if (!this._shouldExportTransformNode(babylonTransformNode)) {
|
|
Tools.Log("Omitting " + babylonTransformNode.name + " from scene.");
|
|
Tools.Log("Omitting " + babylonTransformNode.name + " from scene.");
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- if (this.convertToRightHandedSystem) {
|
|
|
|
|
|
+ if (this._convertToRightHandedSystem) {
|
|
if (glTFNode.translation) {
|
|
if (glTFNode.translation) {
|
|
glTFNode.translation[2] *= -1;
|
|
glTFNode.translation[2] *= -1;
|
|
glTFNode.translation[0] *= -1;
|
|
glTFNode.translation[0] *= -1;
|
|
@@ -1117,15 +1118,15 @@ module BABYLON.GLTF2 {
|
|
if (!glTFNode.children && directDescendents && directDescendents.length) {
|
|
if (!glTFNode.children && directDescendents && directDescendents.length) {
|
|
glTFNode.children = [];
|
|
glTFNode.children = [];
|
|
for (let descendent of directDescendents) {
|
|
for (let descendent of directDescendents) {
|
|
- if (this.nodeMap[descendent.uniqueId] != null) {
|
|
|
|
- glTFNode.children.push(this.nodeMap[descendent.uniqueId]);
|
|
|
|
|
|
+ if (this._nodeMap[descendent.uniqueId] != null) {
|
|
|
|
+ glTFNode.children.push(this._nodeMap[descendent.uniqueId]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
};
|
|
if (scene.nodes.length) {
|
|
if (scene.nodes.length) {
|
|
- this.scenes.push(scene);
|
|
|
|
|
|
+ this._scenes.push(scene);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -1153,12 +1154,12 @@ module BABYLON.GLTF2 {
|
|
if (shouldExportTransformNode(babylonTransformNode)) {
|
|
if (shouldExportTransformNode(babylonTransformNode)) {
|
|
node = this.createNode(babylonTransformNode, binaryWriter);
|
|
node = this.createNode(babylonTransformNode, binaryWriter);
|
|
|
|
|
|
- this.nodes.push(node);
|
|
|
|
- nodeIndex = this.nodes.length - 1;
|
|
|
|
|
|
+ this._nodes.push(node);
|
|
|
|
+ nodeIndex = this._nodes.length - 1;
|
|
nodeMap[babylonTransformNode.uniqueId] = nodeIndex;
|
|
nodeMap[babylonTransformNode.uniqueId] = nodeIndex;
|
|
|
|
|
|
if (!babylonScene.animationGroups.length && babylonTransformNode.animations.length) {
|
|
if (!babylonScene.animationGroups.length && babylonTransformNode.animations.length) {
|
|
- _GLTFAnimation._CreateNodeAnimationFromTransformNodeAnimations(babylonTransformNode, runtimeGLTFAnimation, idleGLTFAnimations, nodeMap, this.nodes, binaryWriter, this.bufferViews, this.accessors, this.convertToRightHandedSystem, this.animationSampleRate);
|
|
|
|
|
|
+ _GLTFAnimation._CreateNodeAnimationFromTransformNodeAnimations(babylonTransformNode, runtimeGLTFAnimation, idleGLTFAnimations, nodeMap, this._nodes, binaryWriter, this._bufferViews, this._accessors, this._convertToRightHandedSystem, this._animationSampleRate);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
@@ -1167,16 +1168,16 @@ module BABYLON.GLTF2 {
|
|
};
|
|
};
|
|
|
|
|
|
if (runtimeGLTFAnimation.channels.length && runtimeGLTFAnimation.samplers.length) {
|
|
if (runtimeGLTFAnimation.channels.length && runtimeGLTFAnimation.samplers.length) {
|
|
- this.animations.push(runtimeGLTFAnimation);
|
|
|
|
|
|
+ this._animations.push(runtimeGLTFAnimation);
|
|
}
|
|
}
|
|
idleGLTFAnimations.forEach((idleGLTFAnimation) => {
|
|
idleGLTFAnimations.forEach((idleGLTFAnimation) => {
|
|
if (idleGLTFAnimation.channels.length && idleGLTFAnimation.samplers.length) {
|
|
if (idleGLTFAnimation.channels.length && idleGLTFAnimation.samplers.length) {
|
|
- this.animations.push(idleGLTFAnimation);
|
|
|
|
|
|
+ this._animations.push(idleGLTFAnimation);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
if (babylonScene.animationGroups.length) {
|
|
if (babylonScene.animationGroups.length) {
|
|
- _GLTFAnimation._CreateNodeAnimationFromAnimationGroups(babylonScene, this.animations, nodeMap, this.nodes, binaryWriter, this.bufferViews, this.accessors, this.convertToRightHandedSystem, this.animationSampleRate);
|
|
|
|
|
|
+ _GLTFAnimation._CreateNodeAnimationFromAnimationGroups(babylonScene, this._animations, nodeMap, this._nodes, binaryWriter, this._bufferViews, this._accessors, this._convertToRightHandedSystem, this._animationSampleRate);
|
|
}
|
|
}
|
|
|
|
|
|
return nodeMap;
|
|
return nodeMap;
|
|
@@ -1203,8 +1204,8 @@ module BABYLON.GLTF2 {
|
|
this.setPrimitiveAttributes(mesh, babylonTransformNode, binaryWriter);
|
|
this.setPrimitiveAttributes(mesh, babylonTransformNode, binaryWriter);
|
|
|
|
|
|
if (mesh.primitives.length) {
|
|
if (mesh.primitives.length) {
|
|
- this.meshes.push(mesh);
|
|
|
|
- node.mesh = this.meshes.length - 1;
|
|
|
|
|
|
+ this._meshes.push(mesh);
|
|
|
|
+ node.mesh = this._meshes.length - 1;
|
|
}
|
|
}
|
|
|
|
|
|
return node;
|
|
return node;
|