I seperate object by scene, but click event not work

I try ti isolate object from the scene and I made this object component

import * as BABYLON from "babylonjs";
const SimpleBox = (scene) => {
	let box;
	let mat = new BABYLON.StandardMaterial("mat", scene);
	mat.diffuseColor = new BABYLON.Color3(1, 0, 0);
	box = BABYLON.MeshBuilder.CreateBox(
		{ height: 5, width: 3, depth: 2 },
	box.material = mat;
	box.position = new BABYLON.Vector3(0, 1, 0);

	box.actionManager = new BABYLON.ActionManager(scene);
	box.actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger, function() {

	return box;
export default SimpleBox;

in the onSceneReady function of main Scene file
I see the box loaded correctly however, the click event not work

I don’t know why.
even click event is correct code because I copy the tutorial

Hello! Can you share your complete project, not just the component?


this is my current code

refer to the babylon react tutorial

From your package.json, I see you’re using both the UMD style package (the babylonjs one) and the ES6 package (@babylonjs/core and others). This is going to cause issues with imports, so that’s one thing to rectify first.

Thanks …!! :slight_smile: IT Solved problem at all … !!! :heart_eyes:
this problem make me sick for a long time !!! and it gone away…! :smiley:

1 Like