mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-05 00:13:10 +02:00
initial knockover blocks
This commit is contained in:
parent
1ba31a840a
commit
43f69a0be9
1 changed files with 130 additions and 22 deletions
|
@ -1,47 +1,155 @@
|
|||
//
|
||||
// createKnockoverBlocks.js
|
||||
//
|
||||
// Script Type: Entity Spawner
|
||||
// Created by James B. Pollack on 9/29/2015
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
//
|
||||
// This script creates a 'stonehenge' formation of physical blocks for testing knock over properties.
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
/*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */
|
||||
|
||||
var blockDimensions={
|
||||
x:0.12,
|
||||
y:0.25,
|
||||
z:0.50
|
||||
|
||||
var BLOCK_GRAVITY = {
|
||||
x: 0,
|
||||
y: -9.8,
|
||||
z: 0
|
||||
};
|
||||
|
||||
var LINEAR_DAMPING = 0.2;
|
||||
|
||||
var RED = {
|
||||
red: 255,
|
||||
green: 0,
|
||||
blue: 0
|
||||
};
|
||||
|
||||
var GREEN = {
|
||||
red: 0,
|
||||
green: 255,
|
||||
blue: 0
|
||||
};
|
||||
|
||||
var BLUE = {
|
||||
red: 0,
|
||||
green: 0,
|
||||
blue: 255
|
||||
};
|
||||
|
||||
var blockDimensions = {
|
||||
x: 0.12,
|
||||
y: 0.25,
|
||||
z: 0.50
|
||||
};
|
||||
|
||||
var centerPosition = {
|
||||
x:
|
||||
y:
|
||||
z:
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0
|
||||
};
|
||||
|
||||
var DISTANCE_IN_FRONT_OF_ME = 2.0;
|
||||
var position = Vec3.sum(MyAvatar.position,
|
||||
Vec3.multiplyQbyV(MyAvatar.orientation, {
|
||||
x: 0,
|
||||
y: 0.0,
|
||||
z: -DISTANCE_IN_FRONT_OF_ME
|
||||
}));
|
||||
|
||||
// var position={
|
||||
// x:0,
|
||||
// y:0,
|
||||
// z:0
|
||||
// };
|
||||
|
||||
var sideBlock1_position = {
|
||||
x:
|
||||
y:
|
||||
z:
|
||||
x: position.x,
|
||||
y: position.y,
|
||||
z: position.z - 0.25
|
||||
};
|
||||
|
||||
|
||||
|
||||
var sideBlock2_position = {
|
||||
x:
|
||||
y:
|
||||
z:
|
||||
x: position.x,
|
||||
y: position.y,
|
||||
z: position.z + 0.25
|
||||
};
|
||||
|
||||
var topBlock_position = {
|
||||
x: position.x,
|
||||
y: position.y + 0.31,
|
||||
z: position.z
|
||||
};
|
||||
|
||||
var sideBlock1_rotation = Quat.fromPitchYawRollDegrees();
|
||||
var sideBlock2_rotation = Quat.fromPitchYawRollDegrees();
|
||||
var topBlock_rotation = Quat.fromPitchYawRollDegrees();
|
||||
var sideBlock1_rotation = Quat.fromPitchYawRollDegrees(90, 90, 0);
|
||||
var sideBlock2_rotation = Quat.fromPitchYawRollDegrees(90, 90, 0);
|
||||
var topBlock_rotation = Quat.fromPitchYawRollDegrees(0, 0, 90);
|
||||
|
||||
var sideBlock1 = Entities.addEntity();
|
||||
var sideBlock2 = Entities.addEntity();
|
||||
var topBlock = Entities.addEntity();
|
||||
var ground = Entities.addEntity();
|
||||
var topBlock = Entities.addEntity({
|
||||
name: 'Top Block',
|
||||
color: BLUE,
|
||||
type: 'Box',
|
||||
shapeType: 'box',
|
||||
dimensions: blockDimensions,
|
||||
position: topBlock_position,
|
||||
rotation: topBlock_rotation,
|
||||
linearDamping: LINEAR_DAMPING,
|
||||
gravity: BLOCK_GRAVITY,
|
||||
collisionsWillMove: true,
|
||||
velocity: {
|
||||
x: 0,
|
||||
y: -0.01,
|
||||
z: 0
|
||||
}
|
||||
});
|
||||
|
||||
var sideBlock1 = Entities.addEntity({
|
||||
name: 'Top Block',
|
||||
color: GREEN,
|
||||
type: 'Box',
|
||||
shapeType: 'box',
|
||||
dimensions: blockDimensions,
|
||||
position: sideBlock1_position,
|
||||
rotation: sideBlock1_rotation,
|
||||
linearDamping: LINEAR_DAMPING,
|
||||
gravity: BLOCK_GRAVITY,
|
||||
collisionsWillMove: true
|
||||
});
|
||||
|
||||
var sideBlock2 = Entities.addEntity({
|
||||
name: 'Side Block',
|
||||
color: GREEN,
|
||||
type: 'Box',
|
||||
shapeType: 'box',
|
||||
dimensions: blockDimensions,
|
||||
position: sideBlock2_position,
|
||||
rotation: sideBlock2_rotation,
|
||||
collsionsWillMove: true,
|
||||
linearDamping: LINEAR_DAMPING,
|
||||
gravity: BLOCK_GRAVITY,
|
||||
collisionsWillMove: true
|
||||
});
|
||||
|
||||
var ground = Entities.addEntity({
|
||||
type: 'Box',
|
||||
dimensions: {
|
||||
x: 2,
|
||||
y: 0.02,
|
||||
z: 1
|
||||
},
|
||||
color: RED,
|
||||
position: {
|
||||
x: position.x,
|
||||
y: position.y - 0.25,
|
||||
z: position.z
|
||||
}
|
||||
});
|
||||
|
||||
function cleanUp() {
|
||||
Entities.deleteEntity(ground);
|
||||
Entities.deleteEntity(topBlock);
|
||||
Entities.deleteEntity(sideBlock1);
|
||||
Entities.deleteEntity(sideBlock2);
|
||||
};
|
||||
Script.scriptEnding.connect(cleanUp);
|
Loading…
Reference in a new issue