Skip to content

Commit

Permalink
chore(composer): clean up unused scene model fields
Browse files Browse the repository at this point in the history
  • Loading branch information
sheilaXu committed Jan 27, 2024
1 parent f7cbac8 commit 9ce8bff
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 25 deletions.
3 changes: 1 addition & 2 deletions packages/scene-composer/public/overlay.scene.json
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,5 @@
}
]
}
},
"defaultCameraIndex": 0
}
}
3 changes: 1 addition & 2 deletions packages/scene-composer/public/scene_1.scene.json
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,5 @@
}
]
}
},
"defaultCameraIndex": 0
}
}
1 change: 0 additions & 1 deletion packages/scene-composer/public/scene_2.scene.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@
]
}
},
"defaultCameraIndex": 0,
"properties": {
"environmentPreset": "neutral"
}
Expand Down
5 changes: 2 additions & 3 deletions packages/scene-composer/src/components/StateManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ const StateManager: React.FC<SceneComposerInternalProps> = ({
const [updatedExternalLibraryConfig, setUpdatedExternalLibraryConfig] = useState<ExternalLibraryConfig | undefined>(
externalLibraryConfig,
);
const baseUrl = useStore(sceneComposerId)((state) => state.getSceneProperty<string>(KnownSceneProperty.BaseUrl));
const messages = useStore(sceneComposerId)((state) => state.getMessages());
const matterportModelId = useStore(sceneComposerId)((state) =>
state.getSceneProperty<string>(KnownSceneProperty.MatterportModelId),
Expand All @@ -114,8 +113,8 @@ const StateManager: React.FC<SceneComposerInternalProps> = ({
const { setActiveCameraSettings, setActiveCameraName } = useActiveCamera();

const standardUriModifier = useMemo(
() => createStandardUriModifier(sceneContentUri || '', baseUrl),
[sceneContentUri, baseUrl],
() => createStandardUriModifier(sceneContentUri || '', undefined),
[sceneContentUri],
);

const isViewing = config.mode === 'Viewing';
Expand Down
1 change: 0 additions & 1 deletion packages/scene-composer/src/interfaces/interfaces.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export interface ISceneNode {
}

export enum KnownSceneProperty {
BaseUrl = 'baseUrl',
EnvironmentPreset = 'environmentPreset',
DataBindingConfig = 'dataBindingConfig',
ComponentSettings = 'componentSettings',
Expand Down
1 change: 0 additions & 1 deletion packages/scene-composer/src/models/SceneModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export interface Scene {
properties?: KeyValuePair;
rules?: Record<string, RuleBasedMap>;
cameras?: Array<Camera>;
defaultCameraIndex?: number;
}

export enum CameraType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -762,9 +762,6 @@ function serializeDocument(document: ISceneDocumentInternal, specVersion: string
: [],

rules,

// TODO: allow picking a default camera, currently it's hard coded as the first camera
defaultCameraIndex: indexedObjectCollector[KnownComponentType.Camera] ? 0 : undefined,
};

return JSON.stringify(exportedScene, ...stringifyArgs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -909,18 +909,18 @@ describe('createSceneDocumentSlice', () => {

it('should be able to getSceneProperty', () => {
const document = {
properties: { baseUrl: 'baseUrlValue' },
properties: { matterportModelId: 'abc' },
};
const get = jest.fn().mockReturnValue({ document }); // fake out get call
const set = jest.fn();

// Act
const { getSceneProperty } = createSceneDocumentSlice(set, get);
const result = getSceneProperty(KnownSceneProperty.BaseUrl);
const result = getSceneProperty(KnownSceneProperty.MatterportModelId);
const result2 = getSceneProperty(KnownSceneProperty.EnvironmentPreset, 'default');

expect(get).toBeCalledTimes(2);
expect(result).toEqual(document.properties.baseUrl);
expect(result).toEqual(document.properties.matterportModelId);
expect(result2).toEqual('default');
});

Expand All @@ -931,24 +931,24 @@ describe('createSceneDocumentSlice', () => {

// Act
const { getSceneProperty } = createSceneDocumentSlice(set, get);
const result = getSceneProperty(KnownSceneProperty.BaseUrl, 'default');
const result = getSceneProperty(KnownSceneProperty.EnvironmentPreset, 'default');

expect(get).toBeCalled();
expect(result).toEqual('default');
});

[{}, { properties: { baseUrl: 'original' } }].forEach((document) => {
[{}, { properties: { environmentPreset: 'neutral' } }].forEach((document) => {
it(`should be able to setSceneProperty ${document.properties ? 'with' : 'without'} set properties`, () => {
const draft = { lastOperation: undefined, document };
const get = jest.fn(); // fake out get call
const set = jest.fn((callback) => callback(draft));

// Act
const { setSceneProperty } = createSceneDocumentSlice(set, get);
setSceneProperty(KnownSceneProperty.BaseUrl, 'setValue');
setSceneProperty(KnownSceneProperty.EnvironmentPreset, 'setValue');

expect(draft.lastOperation!).toEqual('setSceneProperty');
expect(draft.document.properties!.baseUrl).toEqual('setValue');
expect(draft.document.properties!.environmentPreset).toEqual('setValue');
});
});

Expand Down
3 changes: 1 addition & 2 deletions packages/scene-composer/tests/scenes/matterport.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,5 @@
}
]
}
},
"defaultCameraIndex": 0
}
}
3 changes: 1 addition & 2 deletions packages/scene-composer/tests/scenes/scene_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,5 @@
}
]
}
},
"defaultCameraIndex": 0
}
}
1 change: 0 additions & 1 deletion packages/scene-composer/tests/scenes/scene_2.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@
]
}
},
"defaultCameraIndex": 0,
"properties": {
"environmentPreset": "neutral",
"componentSettings": {
Expand Down

0 comments on commit 9ce8bff

Please sign in to comment.