mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
erasing board
This commit is contained in:
parent
e42bbbc10d
commit
8e21999e44
4 changed files with 65 additions and 7 deletions
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// colorSelectorEntityScript.js
|
||||
// examples/toybox/entityScripts
|
||||
// examples/painting/whiteboard
|
||||
//
|
||||
// Created by Eric Levin on 9/21/15.
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
|
|
45
examples/painting/whiteboard/eraseBoardEntityScript.js
Normal file
45
examples/painting/whiteboard/eraseBoardEntityScript.js
Normal file
|
@ -0,0 +1,45 @@
|
|||
//
|
||||
// eraseBoardEntityScript.js
|
||||
// examples/painting/whiteboard
|
||||
//
|
||||
// Created by Eric Levin on 9/21/15.
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
/*global print, MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, Audio, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */
|
||||
/*global BoardEraser */
|
||||
|
||||
(function() {
|
||||
|
||||
var _this;
|
||||
BoardEraser = function() {
|
||||
_this = this;
|
||||
};
|
||||
|
||||
BoardEraser.prototype = {
|
||||
|
||||
startFarGrabNonColliding: function() {
|
||||
this.eraseBoard();
|
||||
},
|
||||
|
||||
clickReleaseOnEntity: function() {
|
||||
this.eraseBoard();
|
||||
},
|
||||
|
||||
eraseBoard: function() {
|
||||
Entities.callEntityMethod(this.whiteboard, "eraseBoard");
|
||||
},
|
||||
|
||||
preload: function(entityID) {
|
||||
this.entityID = entityID;
|
||||
var props = Entities.getEntityProperties(this.entityID, ["userData"]);
|
||||
this.whiteboard = JSON.parse(props.userData).whiteboard;
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
// entity scripts always need to return a newly constructed object of our type
|
||||
return new BoardEraser();
|
||||
});
|
|
@ -82,7 +82,6 @@
|
|||
y: this.currentStrokeWidth
|
||||
}
|
||||
});
|
||||
print("TRIGGER VALUE " + this.triggerValue);
|
||||
if (this.triggerValue > PAINT_TRIGGER_THRESHOLD) {
|
||||
this.paint(this.intersection.intersection, this.intersection.surfaceNormal);
|
||||
} else {
|
||||
|
@ -149,6 +148,7 @@
|
|||
this.currentStroke = Entities.addEntity({
|
||||
position: position,
|
||||
type: "PolyLine",
|
||||
name: "paintStroke",
|
||||
color: this.strokeColor,
|
||||
dimensions: {
|
||||
x: 50,
|
||||
|
@ -171,13 +171,22 @@
|
|||
},
|
||||
|
||||
changeColor: function() {
|
||||
print("CHANGE COLOR");
|
||||
this.strokeColor = JSON.parse(Entities.getEntityProperties(this.entityID, ["userData"]).userData).currentColor;
|
||||
Overlays.editOverlay(this.laserPointer, {
|
||||
color: this.strokeColor
|
||||
});
|
||||
},
|
||||
|
||||
eraseBoard: function() {
|
||||
var entities = Entities.findEntities(this.position, 5);
|
||||
entities.forEach(function(entity) {
|
||||
var name = Entities.getEntityProperties(entity, "name").name;
|
||||
if(name === "paintStroke") {
|
||||
Entities.deleteEntity(entity);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
preload: function(entityID) {
|
||||
this.entityID = entityID;
|
||||
var props = Entities.getEntityProperties(this.entityID, ["position", "rotation", "userData"]);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// whiteBoardSpawner.js
|
||||
// examples/painting
|
||||
// examples/painting/whiteboard
|
||||
//
|
||||
// Created by Eric Levina on 10/12/15.
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
|
@ -92,12 +92,13 @@ var eraseBoxDimensions = {
|
|||
};
|
||||
|
||||
|
||||
var eraseBoxPosition = Vec3.sum(center, Vec3.multiply(direction, whiteboardDimensions.x / 2 + eraseBoxDimensions.x/2));
|
||||
var eraseBoxPosition = Vec3.sum(center, Vec3.multiply(direction, whiteboardDimensions.x / 2 + eraseBoxDimensions.x / 2));
|
||||
eraseBoxPosition.y += 0.3;
|
||||
|
||||
scriptURL = Script.resolvePath("eraseBoardEntityScript.js");
|
||||
var eraseAllText = Entities.addEntity({
|
||||
type: "Text",
|
||||
position: eraseBoxPosition,
|
||||
script: scriptURL,
|
||||
rotation: rotation,
|
||||
dimensions: eraseBoxDimensions,
|
||||
backgroundColor: {
|
||||
|
@ -111,7 +112,10 @@ var eraseAllText = Entities.addEntity({
|
|||
blue: 10
|
||||
},
|
||||
text: "ERASE BOARD",
|
||||
lineHeight: 0.07
|
||||
lineHeight: 0.07,
|
||||
userData: JSON.stringify({
|
||||
whiteboard: whiteboard
|
||||
})
|
||||
});
|
||||
print(JSON.stringify(Entities.getEntityProperties(eraseAllText)))
|
||||
|
||||
|
|
Loading…
Reference in a new issue