Thank you both for the advice!
I just realized that in order to use the latest BabylonJS exporter, I would need to update my Blender, which I did. Even after exporting using the latest BabylonJS exporter, I still have the same issues.
My first section will show my photos of the Blender settings I have used (thank you, JCPalmer, for these settings):
My second section will show my code.
If I am posting way too much information, please let me know.
Section 1: Blender Settings
Light Settings: (Do I need to use this light for shadows, or can I just use another light I create in BabylonJS?)
Mesh Settings
Section 2: Code
Of course, I would prefer whatever is the best way to upload meshes from blender.
Note: The 2 strategies to add shadows to a shadowcaster for me work the same:
this._sun_shadowGenerator.getShadowMap().renderList.push(oneMesh);
and
this._sun_shadowGenerator.addShadowCaster(oneMesh);
Here are all of the different strategies I have attempted.
Way A:
BABYLON.SceneLoader.ImportMesh <-- Successfully adds the mesh, but the mesh does not cast shadows. It can receive shadows.
Code:
var stopCheck = true;
var importedTestMesh;
BABYLON.SceneLoader.ImportMesh("weirdThing_name", "Assets/", "weirdThing.babylon", this._scene, function(newMeshes) {
console.log('importedTestMesh, about to add to shadowCaster. Length newMeshes is :' + newMeshes.length)
for (var oneMesh of newMeshes) {
try {
// this._sun_shadowGenerator.getShadowMap().renderList.push(oneMesh);
this._sun_shadowGenerator.addShadowCaster(oneMesh);
} catch {
alert('importedTestMesh throws error for shadowCaster');
}
}
console.log('importedTestMesh, added to shadowCaster succesfully, starting for loop.')
for (var oneMesh of newMeshes) {
importedTestMesh = oneMesh
importedTestMesh.position = new BABYLON.Vector3(2, 1, 2);
importedTestMesh.rotate(BABYLON.Axis.Y/*Z*/, /*0.45 * *//*0.25 * *//* 0.25 * */ Math.PI / 2, BABYLON.Space.LOCAL);
stopCheck = false;
importedTestMesh.physicsImpostor = new BABYLON.PhysicsImpostor(importedTestMesh, BABYLON.PhysicsImpostor.MeshImpostor, { mass: 0, restitution: 0.0 }, this._scene);
// BABYLON's website says that Cannon's MeshImpostor only collides with Plane and Sphere Meshes. Hopefully, that is not true
importedTestMesh.receiveShadows = true;
}
});
Picture:
Way B:
BABYLON.SceneLoader.Load <-- Says it cannot load the file (.babylon)
BABYLON.SceneLoader.Load("/Assets/", "weirdThing.babylon", this._engine, function(inScene) {
theGame._scene = inScene;
theGame._scene.executeWhenReady(function() {
//My Code
});
});
Way C: AssetLoader <–Does not call an .onSuccess nor an .onError
// I was not able to get AssetsManager (the code in this section) to work. No .onSuccess is called and .onError is not called either
this._assetsManager = new BABYLON.AssetsManager(this._scene);
var addMeshTask_importedTestMesh = this._assetsManager.addMeshTask("spryTileTutorial task", "", "Assets/", "weirdThing.babylon");//"spryTileTutorial.babylon");
addMeshTask_importedTestMesh.onSuccess = function (task) {
var newMeshes = task.loadedMeshes;
alert("addMeshTask_importedTestMesh onSuccess was called");
console.log('importedTestHouseMesh, about to add to shadowCaster. Length newMeshes is :' + newMeshes.length);
// this._sun_shadowGenerator.addShadowCaster(newMeshes);
for (var oneMesh of newMeshes) {
try {
this._sun_shadowGenerator.getShadowMap().renderList.push(oneMesh);
// this._sun_shadowGenerator.addShadowCaster(oneMesh);
} catch {
alert('AssetsManager importedTestMesh throws error for shadowCaster');
}
}
for (var oneMesh of newMeshes) {
var importedTestHouseMesh = oneMesh
importedTestHouseMesh.position = new BABYLON.Vector3(-10, 1, 5);
importedTestHouseMesh.rotate(BABYLON.Axis.Y/*Z*/, /*0.45 * *//*0.25 * *//* 0.25 * */ Math.PI / 2, BABYLON.Space.LOCAL);
// stopCheck2 = false;
importedTestHouseMesh.physicsImpostor = new BABYLON.PhysicsImpostor(importedTestHouseMesh, BABYLON.PhysicsImpostor.MeshImpostor, { mass: 0, restitution: 0.0 }, this._scene);
// BABYLON's website says that Cannon's MeshImpostor only collides with Plane and Sphere Meshes. Hopefully, that is not true
importedTestHouseMesh.receiveShadows = true;
}
}
addMeshTask_importedTestMesh.onError = function (task) {
console.log("addMeshTask_importedTestMesh error function!")
alert("addMeshTask_importedTestMesh error function!")
}