Created
May 21, 2020 07:08
-
-
Save edzis/461dd1f6036509ea942088dbb1a43130 to your computer and use it in GitHub Desktop.
Test for https://github.com/BabylonJS/Babylon.js/pull/8163, to be placed in localDev/src/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var createScene = function () { | |
// Create basic scene | |
var scene = new BABYLON.Scene(engine); | |
var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 5, -10), scene); | |
camera.setTarget(BABYLON.Vector3.Zero()); | |
camera.attachControl(canvas, true); | |
var light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), scene); | |
light.intensity = 0.7; | |
var sphere = BABYLON.Mesh.CreateSphere("sphere1", 16, 2, scene); | |
sphere.rotation.z = Math.PI/2 | |
sphere.position.y = 1; | |
var ground = BABYLON.Mesh.CreateGround("ground1", 6, 6, 2, scene); | |
// Create utility layer the gizmo will be rendered on | |
var utilLayer = new BABYLON.UtilityLayerRenderer(scene); | |
var gizmoManager = new BABYLON.GizmoManager(scene) | |
gizmoManager.boundingBoxGizmoEnabled = true | |
gizmoManager.positionGizmoEnabled = true | |
gizmoManager.rotationGizmoEnabled = true | |
gizmoManager.gizmos.positionGizmo.yPlaneGizmo.isEnabled = true | |
gizmoManager.attachedMesh = sphere; | |
// Keep the gizmo fixed to world rotation | |
gizmoManager.updateGizmoRotationToMatchAttachedMesh = false; | |
// Toggle gizmo on keypress | |
document.onkeydown = ()=>{ | |
gizmo.attachedMesh = !gizmo.attachedMesh ? sphere : null | |
} | |
return scene; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment