mirror of
https://github.com/overte-org/overte.git
synced 2025-07-30 00:30:22 +02:00
parenting visual to sound entity
This commit is contained in:
parent
9edc8aa5aa
commit
deb2c5af63
3 changed files with 36 additions and 8 deletions
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
VRVJSoundEntity.prototype = {
|
VRVJSoundEntity.prototype = {
|
||||||
playSound: function() {
|
playSound: function() {
|
||||||
_this.soundInjector = Audio.playSound(_this.clip, {position: _this.position, volume: 1.0});
|
// _this.soundInjector = Audio.playSound(_this.clip, {position: _this.position, volume: 1.0});
|
||||||
},
|
},
|
||||||
|
|
||||||
preload: function(entityID) {
|
preload: function(entityID) {
|
||||||
|
|
|
@ -1,25 +1,51 @@
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var _this;
|
var _this;
|
||||||
Script.include("../libraries/utils.js");
|
Script.include("../libraries/utils.js");
|
||||||
|
var NULL_UUID = "{00000000-0000-0000-0000-000000000000}";
|
||||||
|
var ZERO_VEC = {x: 0, y: 0, z: 0};
|
||||||
VRVJVisualEntity = function() {
|
VRVJVisualEntity = function() {
|
||||||
_this = this;
|
_this = this;
|
||||||
_this.SOUND_LOOP_NAME
|
_this.SOUND_LOOP_NAME = "VRVJ-Sound-Cartridge";
|
||||||
|
_this.SOUND_CARTRIDGE_SEARCH_RANGE = 0.1;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
VRVJVisualEntity.prototype = {
|
VRVJVisualEntity.prototype = {
|
||||||
|
|
||||||
releaseGrab: function() {
|
releaseGrab: function() {
|
||||||
// search for nearby sound loop entities and if found, add it as a parent
|
print("RELEASE GRAB")
|
||||||
_this.searchForNearbySoundLoops();
|
// search for nearby sound loop entities and if found, add it as a parent
|
||||||
|
Script.setTimeout(function() {
|
||||||
|
_this.searchForNearbySoundLoops();
|
||||||
|
}, 100);
|
||||||
},
|
},
|
||||||
|
|
||||||
searchForNearbySoundLoops: function() {
|
searchForNearbySoundLoops: function() {
|
||||||
|
_this.position = Entities.getEntityProperties(_this.entityID, "position").position;
|
||||||
|
var entities = Entities.findEntities(_this.position, _this.SOUND_CARTRIDGE_SEARCH_RANGE);
|
||||||
|
for (var i = 0; i < entities.length; i++) {
|
||||||
|
var entity = entities[i];
|
||||||
|
var props = Entities.getEntityProperties(entity, ["name"]);
|
||||||
|
if (props.name.indexOf(_this.SOUND_LOOP_NAME) !== -1) {
|
||||||
|
// Need to set a timeout to wait for grab script to stop messing with entity
|
||||||
|
Entities.editEntity(_this.entityID, {
|
||||||
|
parentID: entity,
|
||||||
|
dynamic: false
|
||||||
|
});
|
||||||
|
Script.setTimeout(function() {
|
||||||
|
Entities.editEntity(_this.entityID, {dynamic: true});
|
||||||
|
}, 100);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
Entities.editEntity(_this.entityID, {
|
||||||
|
parentID: NULL_UUID
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
preload: function(entityID) {
|
preload: function(entityID) {
|
||||||
|
print("YAAAA")
|
||||||
_this.entityID = entityID;
|
_this.entityID = entityID;
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
|
@ -16,6 +16,7 @@ var soundEntity = Entities.addEntity({
|
||||||
color: {red: 200, green: 10, blue: 200},
|
color: {red: 200, green: 10, blue: 200},
|
||||||
position: center,
|
position: center,
|
||||||
damping: 1,
|
damping: 1,
|
||||||
|
angularDamping: 1,
|
||||||
dynamic: true,
|
dynamic: true,
|
||||||
script: SOUND_SCRIPT_URL,
|
script: SOUND_SCRIPT_URL,
|
||||||
userData: JSON.stringify({
|
userData: JSON.stringify({
|
||||||
|
@ -23,12 +24,13 @@ var soundEntity = Entities.addEntity({
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
var VISUAL_SCRIPT_URL = Script.resolvePath("VRVJVisualCartridgeEntityScript.js");
|
var VISUAL_SCRIPT_URL = Script.resolvePath("VRVJVisualCartridgeEntityScript.js?v1" + Math.random());
|
||||||
var visualEntity = Entities.addEntity({
|
var visualEntity = Entities.addEntity({
|
||||||
type: "Sphere",
|
type: "Sphere",
|
||||||
name: "VRVJ-Visual-Cartridge",
|
name: "VRVJ-Visual-Cartridge",
|
||||||
dimensions: {x: 0.1, y: 0.1, z: 0.1},
|
dimensions: {x: 0.1, y: 0.1, z: 0.1},
|
||||||
damping: 1,
|
damping: 1,
|
||||||
|
angularDamping: 1,
|
||||||
color: {red: 0, green: 200, blue: 10},
|
color: {red: 0, green: 200, blue: 10},
|
||||||
dynamic: true,
|
dynamic: true,
|
||||||
position: Vec3.sum(center, {x: 0, y: 0.2, z: 0}),
|
position: Vec3.sum(center, {x: 0, y: 0.2, z: 0}),
|
||||||
|
|
Loading…
Reference in a new issue