Skip to content

Commit 814526d

Browse files
authored
Merge pull request #736 from 3DStreet/fix-undo-dynamic-schema
Properly stringify some properties of dynamic schema, fallback to static schema
2 parents f2592b9 + 5e143e9 commit 814526d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/editor/lib/commands/EntityUpdateCommand.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@ export class EntityUpdateCommand extends Command {
3838
this.component = payload.component;
3939
this.property = payload.property;
4040

41-
// const component = this.entity.components[payload.component];
42-
const component = AFRAME.components[payload.component];
43-
// Don't use AFRAME.components[payload.component] here, but use this.entity.components[payload.component] so we have the dynamic schema,
44-
// important for material or geometry components like for example modifying material metalness,
45-
// otherwise component.schema[payload.property] would be undefined.
41+
const component =
42+
this.entity.components[payload.component] ??
43+
AFRAME.components[payload.component];
44+
// First try to get `this.entity.components[payload.component]` to have the dynamic schema, and fallback to `AFRAME.components[payload.component]` if not found.
45+
// This is to properly stringify some properties that uses for example vec2 or vec3 on material component.
46+
// This is important to fallback to `AFRAME.components[payload.component]` for primitive components position rotation and scale
47+
// that may not have been created initially on the entity.
4648
if (component) {
4749
if (payload.property) {
4850
if (component.schema[payload.property]) {

0 commit comments

Comments
 (0)