Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce ModelData class #4940

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions packages/model-viewer/src/three-components/ModelData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {Object3D} from 'three';

/**
* A THREE.Scene object that takes a Model and CanvasHTMLElement and
* constructs a framed scene based off of the canvas dimensions.
* Provides lights and cameras to be used in a renderer.
*/
export class ModelData extends Object3D {
// ModelScene is going to have child of this types
public url: string|null = null;

constructor(url: string) {
super();
this.url = url;
console.log("ModelData constructor is called");
}
}
4 changes: 4 additions & 0 deletions packages/model-viewer/src/three-components/ModelScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {$currentGLTF, $model, $originalGltfJson} from '../features/scene-graph.j
import {$nodeFromIndex, $nodeFromPoint} from '../features/scene-graph/model.js';
import ModelViewerElementBase, {$renderer, EffectComposerInterface, RendererInterface} from '../model-viewer-base.js';
import {ModelViewerElement} from '../model-viewer.js';
import {ModelData} from './ModelData.js';
import {normalizeUnit} from '../styles/conversions.js';
import {NumberNode, parseExpressions} from '../styles/parsers.js';

Expand Down Expand Up @@ -65,6 +66,7 @@ const ndc = new Vector2();
* Provides lights and cameras to be used in a renderer.
*/
export class ModelScene extends Scene {
public modelData: ModelData;
public element: ModelViewerElement;
public canvas: HTMLCanvasElement;
public annotationRenderer = new CSS2DRenderer();
Expand Down Expand Up @@ -120,6 +122,8 @@ export class ModelScene extends Scene {
constructor({canvas, element, width, height}: ModelSceneConfig) {
super();

this.modelData = new ModelData("url.glb");

this.name = 'ModelScene';

this.element = element as ModelViewerElement;
Expand Down
Loading