Accessing ScenLoader from within a class

How would inheritance work if I needed to access SceneLoader from within a class using TS? So in the example below I have main.js./ts and nodes.ts/js. I can not access SceneLoader from within nodes.ts/js but can from main.ts/js. I don’t know why I am stumped on this today :frowning:

main.ts

import { Engine } from “@babylonjs/core/Engines/engine”;
import { Scene } from “@babylonjs/core/scene”;
import { CubeTexture } from “@babylonjs/core/materials/Textures”;
import { PBRMaterial } from “@babylonjs/core/Materials/PBR/pbrMaterial”;
import { Vector3, Color3, Color4 } from “@babylonjs/core/Maths/math”;
import { ArcRotateCamera } from “@babylonjs/core/Cameras/arcRotateCamera”;
import { AutoRotationBehavior } from “@babylonjs/core/Behaviors/Cameras”
import { HemisphericLight } from “@babylonjs/core/Lights/hemisphericLight”;
import { DirectionalLight } from “@babylonjs/core/Lights/directionalLight”;
import { StandardMaterial} from “@babylonjs/core/Materials/standardMaterial”
import { SceneLoader} from “@babylonjs/core/Loading/sceneLoader”
import “@babylonjs/loaders”
import “@babylonjs/core/Meshes/meshBuilder”;
import { pNode } from “./nodes”;

let mediaPath = “./media/”

const canvas = document.getElementById(“renderCanvas”) as HTMLCanvasElement;
const engine = new Engine(canvas);
var scene = new Scene(engine);

//**** Code to create a scene is here - removed for simplicity **/

let nodeInputArray[]; // not actually blank, but removed to clean up code for example
let nodeArray = [];

nodeInputArray.forEach(function(value) {
if(value[3]==0)
{
if(debug){ console.log("Found a project root: " + value[1]);};
// if in technology mode, we don’t render root nodes
if(nodeMode==“project”){
let tempNode = new pNode(mediaPath, “Razana”,“razana”, scene);
}
// load class instance
} else if(value[3]>0 ) {
if(debug){ console.log("Found a sub-project named " + value[1] + " who’s parent is " + value[3]); };
} else {
//fail
if(debug){ console.error(“Error: " + value[1] + " has no known parent type”); };
};
});

node.ts/js:

export class aNode { constructor(nodeName, fileName, scene){ } public makeMesh(mediaPath:string, fileName: string, scene){ let meshPath = mediaPath + "models/" + fileName + "/"; let modelName = fileName + ".gltf" console.log(meshPath); this.mesh = SceneLoader.ImportMesh("", meshPath, fileName, scene, function (scene) { }); } }

//ProjectNode
export class pNode extends aNode {
constructor(mediaPath, public nodeName: string, public fileName: string, scene){
super(nodeName, fileName, scene);
this.makeMesh(mediaPath, fileName, scene);
}
}

Scratch that, found the issue. Thread Closed

1 Like