Skip to content

Instantly share code, notes, and snippets.

View flushpot1125's full-sized avatar

Limes2018 flushpot1125

View GitHub Profile
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()
for(var n=0;n<character_parts.length;n++){
mirrorMaterial.reflectionTexture.renderList.push(character_parts[n]);
}
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");
//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;
// 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)
// 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;
//参考: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');
$ 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.
<!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>
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";
}