Search the Community
Showing results for tags 'worldspacecanvas2d'.
-
I keep getting the console error "o._cacheNode.getInnerPosToRef is not a function". I just want to get it into the scene for now but I can't get it to show. I may be missing something obvious: var mainCanvas = document.getElementById("renderCanvas"); var engine = new BABYLON.Engine(mainCanvas, true); var createScene = function () { // This creates a basic Babylon Scene object (non-mesh) var scene = new BABYLON.Scene(engine); // This creates and positions a free camera (non-mesh) var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 5, -10), scene); camera.setTarget(BABYLON.Vector3.Zero()); camera.attachControl(mainCanvas, true); // This creates a light, aiming 0,1,0 - to the sky (non-mesh) var light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), scene); var text2d = new BABYLON.Text2D("A", { fontName: "24pt Arial", marginAlignment: "h: center, v: bottom", fontSuperSample: true }); var canvas = new BABYLON.WorldSpaceCanvas2D(scene, new BABYLON.Size(150, 150), { id: "WorldSpaceCanvas", worldPosition: new BABYLON.Vector3(0, 0, 0), enableInteraction: true, backgroundFill: "#C0C0C040", backgroundRoundRadius: 20, children: [ text2d ] }); var box1 = BABYLON.Mesh.CreateBox("Box1", 2.0, scene); var materialBox = new BABYLON.StandardMaterial("texture1", scene); materialBox.diffuseColor = new BABYLON.Color3(0, 1, 0);//Green box1.material = materialBox; var animationBox = new BABYLON.Animation("boxAnimation", "position.x", 30, BABYLON.Animation.ANIMATIONTYPE_FLOAT, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE); // Animation keys var keys = []; keys.push({ frame: 0, value: 20 }); keys.push({ frame: 60, value: -10 }); animationBox.setKeys(keys); box1.animations.push(animationBox); scene.beginAnimation(box1, 0, 100, true); return scene; }; var scene = createScene(); engine.runRenderLoop(function () { scene.render(); }); // Resize window.addEventListener("resize", function () { engine.resize(); });
- 8 replies
-
- babylonjs
- worldspacecanvas2d
-
(and 1 more)
Tagged with:
-
Hi everyone! And question again How I can attach the WorldSpaceCanvas2D to some mesh on my scene? Something like WorldSpaceCanvas2D.parent = myMesh. Or I need changing a canvas position and rotation in every frame? Then next question, how I can change the WorldSpaceCanvas2D position and rotation in worldSpace? Thank!
- 2 replies
-
- worldspacecanvas2d
- mesh
-
(and 1 more)
Tagged with:
-
Hi, Please have a look at sample on this link http://babylonjs-playground.com/#1QKRUF#157 I would like to get scrolling working if canvas goes beyond view port. If I zoom in, whole screen is occupied with canvas. I would like to use my mouse or touch to move along canvas, Could anyone please help me to achieve the same? Thanks, Nikhil