mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:44:02 +02:00
Added header to dynamicLoader and removed files that are not ready for merging
This commit is contained in:
parent
c2fe937a5c
commit
3f5cd0237d
3 changed files with 14 additions and 123 deletions
|
@ -1,3 +1,17 @@
|
|||
//
|
||||
// dynamicLoader.js
|
||||
// examples
|
||||
//
|
||||
// Created by Eric Levin on 11/10/2015.
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
//
|
||||
// This is script loads models from a specified directory
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
|
||||
|
||||
var BASE_URL = "https://hifi-public.s3.amazonaws.com/";
|
||||
var models = [];
|
||||
var floorPosition = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(Camera.getOrientation())));;
|
||||
|
|
|
@ -1,82 +0,0 @@
|
|||
var floorPosition = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(Camera.getOrientation())));;
|
||||
floorPosition.y = MyAvatar.position.y - 5;
|
||||
|
||||
Script.include('../libraries/utils.js');
|
||||
|
||||
var entityScriptURL = Script.resolvePath("modelSwap.js");
|
||||
|
||||
var modelsToLoad = [{
|
||||
lowURL: "https://s3.amazonaws.com/hifi-public/ozan/3d_marketplace/sets/dojo/dojo_low.fbx",
|
||||
highURL: "https://s3.amazonaws.com/hifi-public/ozan/3d_marketplace/sets/dojo/dojo_hi.fbx"
|
||||
}, {
|
||||
lowURL: "https://s3.amazonaws.com/hifi-public/ozan/3d_marketplace/sets/tuscany/tuscany_low.fbx",
|
||||
highURL: "https://s3.amazonaws.com/hifi-public/ozan/3d_marketplace/sets/tuscany/tuscany_hi.fbx"
|
||||
}];
|
||||
|
||||
var models = [];
|
||||
|
||||
var floor = Entities.addEntity({
|
||||
type: "Model",
|
||||
modelURL: "https://hifi-public.s3.amazonaws.com/ozan/3d_marketplace/props/floor/3d_mp_floor.fbx",
|
||||
position: floorPosition,
|
||||
shapeType: 'box',
|
||||
dimensions: {
|
||||
x: 1000,
|
||||
y: 9,
|
||||
z: 1000
|
||||
}
|
||||
});
|
||||
|
||||
//Create grid
|
||||
var modelParams = {
|
||||
type: "Model",
|
||||
dimensions: {
|
||||
x: 31.85,
|
||||
y: 7.75,
|
||||
z: 54.51
|
||||
},
|
||||
script: entityScriptURL,
|
||||
userData: JSON.stringify({
|
||||
grabbableKey: {
|
||||
wantsTrigger: true
|
||||
}
|
||||
})
|
||||
|
||||
};
|
||||
|
||||
var modelPosition = {
|
||||
x: floorPosition.x + 10,
|
||||
y: floorPosition.y + 8.5,
|
||||
z: floorPosition.z - 30
|
||||
};
|
||||
for (var i = 0; i < modelsToLoad.length; i++) {
|
||||
modelParams.modelURL = modelsToLoad[i].lowURL;
|
||||
modelParams.position = modelPosition;
|
||||
var lowModel = Entities.addEntity(modelParams);
|
||||
|
||||
modelParams.modelURL = modelsToLoad[i].highURL;
|
||||
modelParams.visible = false;
|
||||
modelParams.dimensions = Vec3.multiply(modelParams.dimensions, 0.5);
|
||||
var highModel = Entities.addEntity(modelParams);
|
||||
models.push({
|
||||
low: lowModel,
|
||||
high: highModel
|
||||
});
|
||||
// customKey, id, data
|
||||
setEntityCustomData('modelCounterpart', lowModel, {modelCounterpartId: highModel});
|
||||
setEntityCustomData('modelCounterpart', highModel, {modelCounterpartId: lowModel});
|
||||
|
||||
modelPosition.z -= 60;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function cleanup() {
|
||||
Entities.deleteEntity(floor);
|
||||
models.forEach(function(model) {
|
||||
Entities.deleteEntity(model.low);
|
||||
Entities.deleteEntity(model.high);
|
||||
});
|
||||
}
|
||||
|
||||
Script.scriptEnding.connect(cleanup);
|
|
@ -1,41 +0,0 @@
|
|||
// When user holds down trigger on model for enough time, the model with do a cool animation and swap out with the low or high version of it
|
||||
|
||||
|
||||
|
||||
(function() {
|
||||
|
||||
var _this;
|
||||
ModelSwaper = function() {
|
||||
_this = this;
|
||||
};
|
||||
|
||||
ModelSwaper.prototype = {
|
||||
|
||||
startFarTrigger: function() {
|
||||
print("START TRIGGER")
|
||||
|
||||
//make self invisible and make the model's counterpart visible!
|
||||
var dimensions = Entities.getEntityProperties(this.entityID, "dimensions").dimensions;
|
||||
Entities.editEntity(this.entityID, {
|
||||
visible: false,
|
||||
dimensions: Vec3.multiply(dimensions, 0.5)
|
||||
});
|
||||
dimensions = Entities.getEntityProperties(this.modelCounterpartId, "dimensions").dimensions;
|
||||
Entities.editEntity(this.modelCounterpartId, {
|
||||
visible: true,
|
||||
dimensions: Vec3.multiply(dimensions, 2)
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
preload: function(entityID) {
|
||||
this.entityID = entityID;
|
||||
var props = Entities.getEntityProperties(this.entityID, ["userData"]);
|
||||
this.modelCounterpartId = JSON.parse(props.userData).modelCounterpart.modelCounterpartId;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// entity scripts always need to return a newly constructed object of our type
|
||||
return new ModelSwaper();
|
||||
});
|
Loading…
Reference in a new issue