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
scene.registerBeforeRender(function () { | |
scene.meshes.forEach(function (m) { | |
if (m.name=="ballInstance" && (m.position.z <-100)||(m.position.z > 100)) { | |
m.dispose(); | |
} | |
}) | |
}); |
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
function shoot () { | |
const ballInstance = bullet.createInstance("ballInstance"); | |
ballInstance.position.copyFrom(reticle.getAbsolutePosition()); | |
ballInstance.physicsImpostor = new BABYLON.PhysicsImpostor(ballInstance, BABYLON.PhysicsImpostor.SphereImpostor, { mass: 1, friction: 0.2, restitution: 0.2 }); | |
ballInstance.applyImpulse(ray.direction.scale(impulseMagnitude), bullet.getAbsolutePosition().add(contactLocalRefPoint)); | |
} |
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 ray; | |
function castRay(){ | |
ray = scene.activeCamera.getForwardRay(); | |
} | |
engine.runRenderLoop(function () { | |
castRay(); | |
}); |
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
/*Sphere reticle*/ | |
var reticle = BABYLON.Mesh.CreateSphere("reticle", 10, .03, scene); | |
var retmat= new BABYLON.StandardMaterial("reticalmaterial", scene); | |
retmat.emissiveColor = BABYLON.Color3.Red(); | |
retmat.specularColor = BABYLON.Color3.Black(); | |
reticle.material = retmat; | |
reticle.isPickable = false; | |
reticle.position.z = 2; | |
reticle.parent = camera; |
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
scene.enablePhysics(); | |
var physicsEngine = scene.getPhysicsEngine(); | |
gravity = new BABYLON.Vector3(0,0,0); | |
physicsEngine.setGravity(gravity); |
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 createLink = function(fontFamily) { | |
var headID = document.head; | |
var link = document.createElement('link'); | |
link.rel = 'stylesheet'; | |
headID.appendChild(link); | |
link.href = 'https://fonts.googleapis.com/css?family=' + fontFamily; | |
} |
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
scene.onKeyboardObservable.add((kbInfo) => { | |
switch (kbInfo.type) { | |
case BABYLON.KeyboardEventTypes.KEYDOWN: | |
switch (kbInfo.event.key) { | |
case "a": | |
console.log("hit"); | |
beta = beta -10; | |
UI.showProgressBar(beta); | |
break |
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 camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 5, -10), scene); | |
// This targets the camera to scene origin | |
//camera.setTarget(BABYLON.Vector3.Zero()); | |
// This attaches the camera to the canvas | |
camera.attachControl(canvas, true); |
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
//Box on Babylon.js | |
var box = BABYLON.MeshBuilder.CreateBox("box", {height:1, width:1, depth:1}); |
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
//explosion.ts | |
export function _generateSmoke( generatePos:Vector3):void{ | |
// Start the particle system | |
let particleSystem:ParticleSystem; | |
let scene : SceneManager; | |
//以降処理が続く | |
} | |
export function _explode(impactPos : Vector3):void{ |