Skip to content

Commit

Permalink
Merge pull request #736 from 3DStreet/fix-undo-dynamic-schema
Browse files Browse the repository at this point in the history
Properly stringify some properties of dynamic schema, fallback to static schema
  • Loading branch information
kfarr authored Jul 29, 2024
2 parents f2592b9 + 5e143e9 commit 814526d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/editor/lib/commands/EntityUpdateCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ export class EntityUpdateCommand extends Command {
this.component = payload.component;
this.property = payload.property;

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

0 comments on commit 814526d

Please sign in to comment.