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
func _integrate_forces(state): | |
var delta = state.get_step() | |
var lv = state.get_linear_velocity() | |
var g = state.get_total_gravity() | |
# get_total_gravity returns zero for the first few frames, leading to errors. | |
if g == Vector3.ZERO: | |
g = gravity | |
lv += g * delta # Apply gravity. | |
var up = -g.normalized() |
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
for(var n=0;n<character_parts.length;n++){ | |
mirrorMaterial.reflectionTexture.renderList.push(character_parts[n]); | |
} |
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
BABYLON.SceneLoader.ImportMesh("", "https://assets.babylonjs.com/meshes/", "HVGirl.glb", scene, function (newMeshes, particleSystems, skeletons, animationGroups) { | |
var hero = newMeshes[0]; | |
//Scale the model down | |
hero.scaling.scaleInPlace(0.1); | |
//Lock camera on the character | |
camera.target = hero; | |
//Get the Samba animation Group | |
const sambaAnim = scene.getAnimationGroupByName("Samba"); |
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
//Create reflecting surface for mirror surface | |
var reflector = new BABYLON.Plane.FromPositionAndNormal(glass.position, glassNormal.scale(-1)); | |
//Create the mirror material | |
var mirrorMaterial = new BABYLON.StandardMaterial("mirror", scene); | |
mirrorMaterial.reflectionTexture = new BABYLON.MirrorTexture("mirror", 1024, scene, true); | |
mirrorMaterial.reflectionTexture.mirrorPlane = reflector; |
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
// Create behaviors to drag and scale with pointers in VR | |
var sixDofDragBehavior = new BABYLON.SixDofDragBehavior() | |
boundingBox.addBehavior(sixDofDragBehavior) | |
var multiPointerScaleBehavior = new BABYLON.MultiPointerScaleBehavior() | |
boundingBox.addBehavior(multiPointerScaleBehavior) |
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
// wrap in bounding box mesh to avoid picking perf hit | |
var gltfMesh = container.meshes[0] | |
var boundingBox = BABYLON.BoundingBoxGizmo.MakeNotPickableAndWrapInBoundingBox(gltfMesh) | |
// Create bounding box gizmo | |
var utilLayer = new BABYLON.UtilityLayerRenderer(scene) | |
utilLayer.utilityLayerScene.autoClearDepthAndStencil = false; | |
var gizmo = new BABYLON.BoundingBoxGizmo(BABYLON.Color3.FromHexString("#0984e3"), utilLayer) | |
gizmo.attachedMesh = boundingBox; |
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
//参考:https://qiita.com/10mi8o/items/2477f2640291f0ce6687 | |
//参考:https://qiita.com/chocomint_t/items/4bc57945bce081922582 | |
/* pathモジュールを使ってwebページとして出力するパスを指定する。 | |
"path.resolveは、引数をつなげて絶対パスに変換する" | |
"__dirname"は、実行集のソースコードが格納されているディレクトリパス | |
参考:https://gist.github.com/uupaa/da42698d6b2d2cbb3cca | |
*/ | |
const path = require('path'); | |
//const outputPath = path.resolve(__dirname, 'dist'); |
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
$ npx webpack-dev-server | |
[webpack-cli] Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<title>Babylon.js sample code</title> | |
<!-- Babylon.js --> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.6.2/dat.gui.min.js"></script> | |
<script src="https://assets.babylonjs.com/generated/Assets.js"></script> |
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
engine.runRenderLoop(() => { | |
const startCPUTime = BABYLON.PrecisionDate.Now; | |
scene.render(); | |
const endCPUTime = BABYLON.PrecisionDate.Now; | |
t = (t + 1) % 10; | |
// Prevent hammering the composition. | |
if (t === 0) { | |
divFps.innerHTML = engine.getFps().toFixed() + " fps - " + ((endCPUTime - startCPUTime)).toFixed(2) + " CPU ms"; | |
} |
NewerOlder