Questions about meshes loaded in the scene?

Hello guys, I’m here again. I imported meshes into Babylon(from 3ds Max), about 200 meshes in total. I want to operate on some of them. How can I get them? I know the problem may be simple, but I am a beginner, and don’t know how to do. And I want to know how to apply collisions to all meshes besides declaring one by one.

Hey no worries!
So to get a specific mesh, the best is to use scene.getMeshByName("foo").

Then if you want to apply something to all of them:

scene.meshes.forEach(m => {
 m.checkCollisions = true
1 Like

Good question!
And thanks for the answer Deltakosh but its again all code which we artists dont know how to deal with.

Where should we put this code?
Is there a way todo that in the editor?

Pinging @julien-moreau for the editor question

Also pinging @PirateJC because he could be interested to chat with you @oglu

@oglu you can with the editor
When you select a mesh, in the tab “Physics” in the edition tool you have a folder named “Collisions”. Just check or uncheck to the “Check Collisions”.

Don’t forget to also check “Check Collisions” in the “Physics” tab

Thanks Julien, will that be saved with editor if the objects are comming from maya ?

@oglu unfortunately not if the object comes from Maya :frowning:
Added my work on deltas on top of all my other tasks to avoid this kind of problems

Is it not possible to configure collisions from Maya? I know that it’s available in 3ds Max and Blender using the exporter

Thanks Julien!
Collisions arnt in the feature list for the maya exporter.

Thank you very much for your help. I got inspiration from it, and then I solved this problem by traversing array elements:

            BABYLON.SceneLoader.ImportMeshAsync(null, "model/bowuguan/"l, "4.babylon", 
            scene).then(function (result)
                for(var i=0;i<result.meshes.length;i++)
                { result.meshes[i].checkCollisions = true; }
            ]).then(() => {   });

I can’t make it sense with the code you gave to me. Should I change “scene” to “result”? Or I put it in the wrong place. I haven’t been very clear about the data structure, and the official website seldom talks about it.

And I found that once I added

createDefaultVRExperience ();,

Opening the scene defaults to deviceOrientationVRHelper as the camera, and I don’t know how to control it with code.

And another new problems have arisen. I successfully imported the model on the PC and browsed it on the Web, but when I sent the whole file to my mobile phone, I could not display the model I imported. I want to know what I need to do if I want to display it on my mobile phone. This is very important for me, because the resolution requirement of the mobile terminal is lower.

here is my codes

Thank you again.

Here is my codes:

var canvas = document.getElementById(“renderCanvas”);

var delayCreateScene = function () {
    var scene = new BABYLON.Scene(engine);

    var light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 4, 0), scene);
    light.intensity = 5;

    var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(-25, 180.8,860), scene);
    camera.setTarget(new BABYLON.Vector3(0,181,-100));
    camera.attachControl(canvas, true);

    var skybox = BABYLON.MeshBuilder.CreateBox("skyBox", {size:5000.0}, scene);
    skybox.position= new BABYLON.Vector3(0,0,0);
    var skyboxMaterial = new BABYLON.StandardMaterial("skyBox", scene);
    skyboxMaterial.backFaceCulling = false;

    var videoTexture = new BABYLON.VideoTexture("video", ["video/01.mp4"], scene, false, false);
    videoTexture.wrapU = BABYLON.Texture.CLAMP_ADDRESSMODE;
    videoTexture.wrapV = BABYLON.Texture.CLAMP_ADDRESSMODE; = "anonymous";

    skyboxMaterial.reflectionTexture = videoTexture;
    skyboxMaterial.reflectionTexture.coordinatesMode = BABYLON.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
    skyboxMaterial.diffuseColor = new BABYLON.Color3(0, 0, 0);
    skyboxMaterial.specularColor = new BABYLON.Color3(0, 0, 0);

    skybox.material = skyboxMaterial;

    scene.onPointerUp = function () {;

    var baseUrl = "model/bowuguan/";


        BABYLON.SceneLoader.ImportMeshAsync(null, baseUrl , "4.babylon", scene).then
        (function (result)
            for(var i=0;i<result.meshes.length;i++)
                result.meshes[i].checkCollisions = true;

    ]).then(() => { });

    scene.gravity = new BABYLON.Vector3(0, -9.8, 0);
    camera.applyGravity = true;
    camera.ellipsoid = new BABYLON.Vector3(10, 80, 10);

    scene.collisionsEnabled = true;
    camera.checkCollisions = true;;
    return scene;

var engine = new BABYLON.Engine(canvas, true, { preserveDrawingBuffer: true, stencil: true });
var scene = delayCreateScene();

engine.runRenderLoop(function () {
    if (scene) {

// Resize
window.addEventListener("resize", function () {

Well this should work. If this is not the case the best idea is to reproduce your code in the Playground

(here is a doc to reference external assets: Using External Assets - Babylon.js Documentation)