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{ |
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
//move.ts | |
import Test from "./test"; | |
private _test:Test; | |
public onStart(): void { | |
console.log(this._test._testNumber); | |
this._test.showLog(); | |
} | |
// |
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
ballInstance.actionManager = new ActionManager(this._scene); | |
ballInstance.actionManager.registerAction( | |
new ExecuteCodeAction( | |
{ | |
trigger: ActionManager.OnIntersectionEnterTrigger, | |
parameter: this._largeRock, | |
}, | |
() => { | |
_generateSmoke(ballInstance.position); | |
_explode(this._largeRock.position); |
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
private _impluseShot():void{ | |
const ballInstance = this._ball.createInstance("ballInstance"); | |
ballInstance.position.copyFrom(this._ball.getAbsolutePosition()); | |
ballInstance.scaling = new Vector3(10,10,10); | |
ballInstance.isVisible=false;//非表示になる | |
//・・・ |
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
private _swordSlashAnimNoExeFlag : boolean; | |
public onUpdate(): void { | |
if(this._swordSlashAnimNoExeFlag == false){//剣を振るアニメーションが発動されていたらif文を通過する | |
if(this._animSwordAndShieldSlash.animatables[0].animationStarted == true){//アニメーションが実行されていないと、animationStartedが存在しないと表示され処理が止まる | |
if (this._animSwordAndShieldSlash.animatables[0].masterFrame < 0.8 && this._animSwordAndShieldSlash.animatables[0].masterFrame > 0.7){ | |
this._impluseShot();//衝撃波を発生させる関数 | |
this._swordSlashAnimFlag = true;//もう一度呼ばれないように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
//Referred from https://playground.babylonjs.com/#0YT4XN#5 | |
var pointLight = new BABYLON.PointLight("light1", new BABYLON.Vector3(0, 0, 0), scene); | |
pointLight.intensity = 2; | |
pointLight.diffuse = new BABYLON.Color3(0.59, 0.48, 0.33) | |
pointLight.parent = sphere |
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
@onKeyboardEvent([75], KeyboardEventTypes.KEYUP)//K | |
private _impluseShot():void{ | |
// Create a new ball instance | |
const ballInstance = this._ball.createInstance("ballInstance"); | |
ballInstance.position.copyFrom(this._ball.getAbsolutePosition()); | |
ballInstance.scaling = new Vector3(10,10,10); | |
ballInstance.isVisible=false;//ballを見えなくして光だけにする | |
this._trailMeshBall = new TrailMesh("shockWave",ballInstance,this._scene,.1,30,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
var glowLayer = new BABYLON.GlowLayer ("glow",scene); | |
glowLayer.customEmissiveColorSelector = function(mesh, subMesh, material, result) { | |
if (mesh.name === "shockWave") { | |
result.set(1, 0.63, 0.3, 1);// orange glow layer | |
} else { | |
result.set(0, 0, 0, 0);//no glow layer | |
} | |
} |