mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 01:17:14 +02:00
Merge pull request #6884 from ericrius1/junkyardReset
Junkyard reset script
This commit is contained in:
commit
18a1f0884e
3 changed files with 129 additions and 0 deletions
31
examples/junkyard/junkyardClientReset.js
Normal file
31
examples/junkyard/junkyardClientReset.js
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
//
|
||||||
|
// junkyardClientReset.js
|
||||||
|
// examples/junkyard
|
||||||
|
//
|
||||||
|
// Created by Eric Levin on 1/21/16.
|
||||||
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// This script resets the junkyard scene
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
var IMPORT_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/arfs/junkyard.json";
|
||||||
|
var PASTE_ENTITIES_LOCATION = {x: 0, y: 0, z: 0};
|
||||||
|
reset();
|
||||||
|
|
||||||
|
function reset() {
|
||||||
|
// Delete everything and re-import the junkyard arf
|
||||||
|
var e = Entities.findEntities(MyAvatar.position, 1000);
|
||||||
|
for (i = 0; i < e.length; i++) {
|
||||||
|
Entities.deleteEntity(e[i]);
|
||||||
|
}
|
||||||
|
importAssetResourceFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
function importAssetResourceFile() {
|
||||||
|
Clipboard.importEntities(IMPORT_URL);
|
||||||
|
Clipboard.pasteEntities(PASTE_ENTITIES_LOCATION);
|
||||||
|
}
|
53
examples/junkyard/junkyardResetEntityScript.js
Normal file
53
examples/junkyard/junkyardResetEntityScript.js
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
// junkyardResetEntityScript.js
|
||||||
|
//
|
||||||
|
// Script Type: Entity
|
||||||
|
// Created by Eric Levin on 1/20/16.
|
||||||
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// This entity script resets the junkyard when triggered
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
Script.include("../libraries/utils.js");
|
||||||
|
var _this;
|
||||||
|
var IMPORT_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/arfs/junkyard.json";
|
||||||
|
var PASTE_ENTITIES_LOCATION = {x: 0, y: 0, z: 0};
|
||||||
|
var JunkyardResetter = function() {
|
||||||
|
_this = this;
|
||||||
|
};
|
||||||
|
|
||||||
|
JunkyardResetter.prototype = {
|
||||||
|
|
||||||
|
clickReleaseOnEntity: function(entityId, mouseEvent) {
|
||||||
|
if (!mouseEvent.isLeftButton) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.reset();
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
reset: function() {
|
||||||
|
// Delete everything and re-import the junkyard arf
|
||||||
|
var e = Entities.findEntities(MyAvatar.position, 1000);
|
||||||
|
for (i = 0; i < e.length; i++) {
|
||||||
|
// Don't delete our reset entity
|
||||||
|
if (JSON.stringify(this.entityID) !== JSON.stringify(e[i])) {
|
||||||
|
Entities.deleteEntity(e[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.importAssetResourceFile();
|
||||||
|
},
|
||||||
|
|
||||||
|
importAssetResourceFile: function() {
|
||||||
|
Clipboard.importEntities(IMPORT_URL);
|
||||||
|
Clipboard.pasteEntities(PASTE_ENTITIES_LOCATION);
|
||||||
|
},
|
||||||
|
|
||||||
|
preload: function(entityID) {
|
||||||
|
this.entityID = entityID;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
return new JunkyardResetter();
|
||||||
|
});
|
45
examples/junkyard/junkyardResetEntitySpawner.js
Normal file
45
examples/junkyard/junkyardResetEntitySpawner.js
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
//
|
||||||
|
// junkyardResetEntitySpawner.js
|
||||||
|
// examples/junkyard
|
||||||
|
//
|
||||||
|
// Created by Eric Levin on 1/20/16.
|
||||||
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// This script spawns an entity which, when triggered, will reset the junkyard
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
var orientation = Camera.getOrientation();
|
||||||
|
orientation = Quat.safeEulerAngles(orientation);
|
||||||
|
orientation.x = 0;
|
||||||
|
orientation = Quat.fromVec3Degrees(orientation);
|
||||||
|
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(orientation)));
|
||||||
|
|
||||||
|
|
||||||
|
var SCRIPT_URL = Script.resolvePath("junkyardResetEntityScript.js");
|
||||||
|
var MODEL_URL = "http://hifi-content.s3.amazonaws.com/caitlyn/dev/Blueprint%20Objects/Asylum/Asylum_Table/Asylum_Table.fbx";
|
||||||
|
var resetEntity = Entities.addEntity({
|
||||||
|
type: "Model",
|
||||||
|
modelURL: MODEL_URL,
|
||||||
|
position: center,
|
||||||
|
script: SCRIPT_URL,
|
||||||
|
dimensions: {
|
||||||
|
x: 2.8,
|
||||||
|
y: 1.76,
|
||||||
|
z: 1.32
|
||||||
|
},
|
||||||
|
color: {
|
||||||
|
red: 200,
|
||||||
|
green: 10,
|
||||||
|
blue: 200
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function cleanup() {
|
||||||
|
Entities.deleteEntity(resetEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
Script.scriptEnding.connect(cleanup);
|
Loading…
Reference in a new issue