|
@@ -237,10 +237,12 @@ export class Mesh extends AbstractMesh implements IGetSetVerticesData {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- if (value && this._internalMeshDataInfo._sourcePositions && this._internalMeshDataInfo._sourceNormals) {
|
|
|
|
|
|
+ if (value && this._internalMeshDataInfo._sourcePositions) {
|
|
// switch from software to GPU computation: we need to reset the vertex and normal buffers that have been updated by the software process
|
|
// switch from software to GPU computation: we need to reset the vertex and normal buffers that have been updated by the software process
|
|
this.setVerticesData(VertexBuffer.PositionKind, this._internalMeshDataInfo._sourcePositions.slice(), true);
|
|
this.setVerticesData(VertexBuffer.PositionKind, this._internalMeshDataInfo._sourcePositions.slice(), true);
|
|
- this.setVerticesData(VertexBuffer.NormalKind, this._internalMeshDataInfo._sourceNormals.slice(), true);
|
|
|
|
|
|
+ if (this._internalMeshDataInfo._sourceNormals) {
|
|
|
|
+ this.setVerticesData(VertexBuffer.NormalKind, this._internalMeshDataInfo._sourceNormals.slice(), true);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
this._internalAbstractMeshDataInfo._computeBonesUsingShaders = value;
|
|
this._internalAbstractMeshDataInfo._computeBonesUsingShaders = value;
|
|
@@ -4100,9 +4102,6 @@ export class Mesh extends AbstractMesh implements IGetSetVerticesData {
|
|
if (!this.isVerticesDataPresent(VertexBuffer.PositionKind)) {
|
|
if (!this.isVerticesDataPresent(VertexBuffer.PositionKind)) {
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
- if (!this.isVerticesDataPresent(VertexBuffer.NormalKind)) {
|
|
|
|
- return this;
|
|
|
|
- }
|
|
|
|
if (!this.isVerticesDataPresent(VertexBuffer.MatricesIndicesKind)) {
|
|
if (!this.isVerticesDataPresent(VertexBuffer.MatricesIndicesKind)) {
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
@@ -4110,6 +4109,8 @@ export class Mesh extends AbstractMesh implements IGetSetVerticesData {
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ const hasNormals = this.isVerticesDataPresent(VertexBuffer.NormalKind);
|
|
|
|
+
|
|
let internalDataInfo = this._internalMeshDataInfo;
|
|
let internalDataInfo = this._internalMeshDataInfo;
|
|
|
|
|
|
if (!internalDataInfo._sourcePositions) {
|
|
if (!internalDataInfo._sourcePositions) {
|
|
@@ -4118,7 +4119,7 @@ export class Mesh extends AbstractMesh implements IGetSetVerticesData {
|
|
this.subMeshes = submeshes;
|
|
this.subMeshes = submeshes;
|
|
}
|
|
}
|
|
|
|
|
|
- if (!internalDataInfo._sourceNormals) {
|
|
|
|
|
|
+ if (hasNormals && !internalDataInfo._sourceNormals) {
|
|
this.setNormalsForCPUSkinning();
|
|
this.setNormalsForCPUSkinning();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -4136,12 +4137,14 @@ export class Mesh extends AbstractMesh implements IGetSetVerticesData {
|
|
// normalsData checks for not being Float32Array will only pass at most once
|
|
// normalsData checks for not being Float32Array will only pass at most once
|
|
var normalsData = this.getVerticesData(VertexBuffer.NormalKind);
|
|
var normalsData = this.getVerticesData(VertexBuffer.NormalKind);
|
|
|
|
|
|
- if (!normalsData) {
|
|
|
|
- return this;
|
|
|
|
- }
|
|
|
|
|
|
+ if (hasNormals) {
|
|
|
|
+ if (!normalsData) {
|
|
|
|
+ return this;
|
|
|
|
+ }
|
|
|
|
|
|
- if (!(normalsData instanceof Float32Array)) {
|
|
|
|
- normalsData = new Float32Array(normalsData);
|
|
|
|
|
|
+ if (!(normalsData instanceof Float32Array)) {
|
|
|
|
+ normalsData = new Float32Array(normalsData);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
var matricesIndicesData = this.getVerticesData(VertexBuffer.MatricesIndicesKind);
|
|
var matricesIndicesData = this.getVerticesData(VertexBuffer.MatricesIndicesKind);
|
|
@@ -4185,14 +4188,18 @@ export class Mesh extends AbstractMesh implements IGetSetVerticesData {
|
|
Vector3.TransformCoordinatesFromFloatsToRef(internalDataInfo._sourcePositions[index], internalDataInfo._sourcePositions[index + 1], internalDataInfo._sourcePositions[index + 2], finalMatrix, tempVector3);
|
|
Vector3.TransformCoordinatesFromFloatsToRef(internalDataInfo._sourcePositions[index], internalDataInfo._sourcePositions[index + 1], internalDataInfo._sourcePositions[index + 2], finalMatrix, tempVector3);
|
|
tempVector3.toArray(positionsData, index);
|
|
tempVector3.toArray(positionsData, index);
|
|
|
|
|
|
- Vector3.TransformNormalFromFloatsToRef(internalDataInfo._sourceNormals[index], internalDataInfo._sourceNormals[index + 1], internalDataInfo._sourceNormals[index + 2], finalMatrix, tempVector3);
|
|
|
|
- tempVector3.toArray(normalsData, index);
|
|
|
|
|
|
+ if (hasNormals) {
|
|
|
|
+ Vector3.TransformNormalFromFloatsToRef(internalDataInfo._sourceNormals[index], internalDataInfo._sourceNormals[index + 1], internalDataInfo._sourceNormals[index + 2], finalMatrix, tempVector3);
|
|
|
|
+ tempVector3.toArray(normalsData!, index);
|
|
|
|
+ }
|
|
|
|
|
|
finalMatrix.reset();
|
|
finalMatrix.reset();
|
|
}
|
|
}
|
|
|
|
|
|
this.updateVerticesData(VertexBuffer.PositionKind, positionsData);
|
|
this.updateVerticesData(VertexBuffer.PositionKind, positionsData);
|
|
- this.updateVerticesData(VertexBuffer.NormalKind, normalsData);
|
|
|
|
|
|
+ if (hasNormals) {
|
|
|
|
+ this.updateVerticesData(VertexBuffer.NormalKind, normalsData!);
|
|
|
|
+ }
|
|
|
|
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|