Skip to content

Instantly share code, notes, and snippets.

View flushpot1125's full-sized avatar

Limes2018 flushpot1125

View GitHub Profile
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));
}
var ray;
function castRay(){
ray = scene.activeCamera.getForwardRay();
}
engine.runRenderLoop(function () {
castRay();
});
/*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;
scene.enablePhysics();
var physicsEngine = scene.getPhysicsEngine();
gravity = new BABYLON.Vector3(0,0,0);
physicsEngine.setGravity(gravity);
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
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);
//Box on Babylon.js
var box = BABYLON.MeshBuilder.CreateBox("box", {height:1, width:1, depth:1});
//explosion.ts
export function _generateSmoke( generatePos:Vector3):void{
// Start the particle system
let particleSystem:ParticleSystem;
let scene : SceneManager;
//以降処理が続く
}
export function _explode(impactPos : Vector3):void{
//move.ts
import Test from "./test";
private _test:Test;
public onStart(): void {
console.log(this._test._testNumber);
this._test.showLog();
}
//