Skip to content

Commit

Permalink
Fix registerInstancedBuffer after Mesh creation (#12609)
Browse files Browse the repository at this point in the history
* Fix prepass view uniform

* Format

* PBR refractionIntensityTexture in the inspector

* Fix registerInstancedBuffer after Mesh creation

* Fix Shadows after unparenting

* PR feedback
  • Loading branch information
sebavan committed May 31, 2022
1 parent 6380265 commit 4c593b5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
9 changes: 9 additions & 0 deletions packages/dev/core/src/Lights/shadowLight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,4 +387,13 @@ export abstract class ShadowLight extends Light implements IShadowLight {
}
return this;
}

/** @hidden */
protected _syncParentEnabledState() {
super._syncParentEnabledState();
if (!this.parent || !this.parent.getWorldMatrix) {
(this.transformedPosition as any) = null;
(this.transformedDirection as any) = null;
}
}
}
18 changes: 11 additions & 7 deletions packages/dev/core/src/Meshes/instancedMesh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -597,13 +597,15 @@ Mesh.prototype.registerInstancedBuffer = function (kind: string, stride: number)
instance.instancedBuffers = {};
}

this._userInstancedBuffersStorage = {
data: {},
vertexBuffers: {},
strides: {},
sizes: {},
vertexArrayObjects: this.getEngine().getCaps().vertexArrayObject ? {} : undefined,
};
if (!this._userInstancedBuffersStorage) {
this._userInstancedBuffersStorage = {
data: {},
vertexBuffers: {},
strides: {},
sizes: {},
vertexArrayObjects: this.getEngine().getCaps().vertexArrayObject ? {} : undefined,
};
}
}

// Creates an empty property for this kind
Expand All @@ -619,6 +621,8 @@ Mesh.prototype.registerInstancedBuffer = function (kind: string, stride: number)
}

this._invalidateInstanceVertexArrayObject();

this._markSubMeshesAsAttributesDirty();
};

Mesh.prototype._processInstancedBuffers = function (visibleInstances: InstancedMesh[], renderSelf: boolean) {
Expand Down

0 comments on commit 4c593b5

Please sign in to comment.