mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 04:12:46 +02:00
starts
This commit is contained in:
parent
c05849714b
commit
42ec6de512
1 changed files with 71 additions and 37 deletions
|
@ -12,6 +12,18 @@
|
||||||
|
|
||||||
var TANK_SEARCH_RADIUS = 5;
|
var TANK_SEARCH_RADIUS = 5;
|
||||||
|
|
||||||
|
var INTERSECT_COLOR = {
|
||||||
|
red: 255,
|
||||||
|
green: 0,
|
||||||
|
blue: 255
|
||||||
|
}
|
||||||
|
|
||||||
|
var NO_INTERSECT_COLOR = {
|
||||||
|
red: 0,
|
||||||
|
green: 255,
|
||||||
|
blue: 0
|
||||||
|
}
|
||||||
|
|
||||||
function FishTank() {
|
function FishTank() {
|
||||||
_this = this;
|
_this = this;
|
||||||
}
|
}
|
||||||
|
@ -127,6 +139,7 @@
|
||||||
unload: function() {
|
unload: function() {
|
||||||
print(' UNLOAD')
|
print(' UNLOAD')
|
||||||
Script.update.disconnect(_this.update);
|
Script.update.disconnect(_this.update);
|
||||||
|
_this.overlayLineOff();
|
||||||
if (baton) {
|
if (baton) {
|
||||||
print('BATON RELEASE ')
|
print('BATON RELEASE ')
|
||||||
baton.release(function() {});
|
baton.release(function() {});
|
||||||
|
@ -139,51 +152,69 @@
|
||||||
if (iOwn === false) {
|
if (iOwn === false) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
print('i am the owner!')
|
// print('i am the owner!')
|
||||||
//do stuff
|
//do stuff
|
||||||
updateFish();
|
updateFish();
|
||||||
|
_this.seeIfOwnerIsLookingAtTheTank();
|
||||||
},
|
},
|
||||||
debugLookSpot: null,
|
|
||||||
createDebugLookAtCube: function() {
|
overlayLine: null,
|
||||||
var cubePosition = {
|
|
||||||
x: 0,
|
overlayLineOn: function(closePoint, farPoint, color) {
|
||||||
y: 0,
|
print('closePoint: ' + JSON.stringify(closePoint));
|
||||||
z: 0
|
print('farPoint: ' + JSON.stringify(farPoint));
|
||||||
};
|
if (_this.overlayLine === null) {
|
||||||
var cubeSize = 0.03;
|
var lineProperties = {
|
||||||
_this.debugLookAtCube = Overlays.addOverlay("cube", {
|
lineWidth: 5,
|
||||||
position: cubePosition,
|
start: closePoint,
|
||||||
size: cubeSize,
|
end: farPoint,
|
||||||
color: {
|
color: color,
|
||||||
red: 0,
|
ignoreRayIntersection: true, // always ignore this
|
||||||
green: 255,
|
visible: true,
|
||||||
blue: 0
|
alpha: 1
|
||||||
},
|
};
|
||||||
alpha: 1,
|
this.overlayLine = Overlays.addOverlay("line3d", lineProperties);
|
||||||
solid: false
|
|
||||||
});
|
} else {
|
||||||
|
var success = Overlays.editOverlay(_this.overlayLine, {
|
||||||
|
lineWidth: 5,
|
||||||
|
start: closePoint,
|
||||||
|
end: farPoint,
|
||||||
|
color: color,
|
||||||
|
visible: true,
|
||||||
|
ignoreRayIntersection: true, // always ignore this
|
||||||
|
alpha: 1
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
updateDebugLookAtCube: function() {
|
|
||||||
var lookAt3D = HMD.getHUDLookAtPosition3D();
|
overlayLineOff: function() {
|
||||||
_this.lookAt3D = lookAt3D;
|
if (_this.overlayLine !== null) {
|
||||||
Overlays.editOverlay(_this.debugLookAtCube, {
|
Overlays.deleteOverlay(this.overlayLine);
|
||||||
position: lookAt3D
|
}
|
||||||
});
|
_this.overlayLine = null;
|
||||||
},
|
},
|
||||||
seeIfOwnerIsLookingAtTheTank: function(origin,direction) {
|
|
||||||
// var cameraPosition = Camera.getPosition();
|
overlayLineDistance: 3,
|
||||||
// var cameraOrientation = Camera.getOrientation();
|
|
||||||
|
seeIfOwnerIsLookingAtTheTank: function() {
|
||||||
|
var cameraPosition = Camera.getPosition();
|
||||||
|
var cameraOrientation = Camera.getOrientation();
|
||||||
|
|
||||||
|
var front = Quat.getFront(cameraOrientation);
|
||||||
var pickRay = {
|
var pickRay = {
|
||||||
origin: origin,
|
origin: cameraPosition,
|
||||||
direction: direction
|
direction: front
|
||||||
};
|
};
|
||||||
var intersection = Entities.findRayIntersection(pickRay, true, [_this.entityID], [])
|
|
||||||
|
|
||||||
if (intersection.intersects && intersection.entityID = _this.entityID) {
|
_this.overlayLineOn(pickRay.origin, Vec3.sum(pickRay.origin, Vec3.multiply(front, _this.overlayLineDistance)), INTERSECT_COLOR);
|
||||||
|
|
||||||
print('looking at the tank!! ' + JSON.stringify(intersection.intersection));
|
var intersection = Entities.findRayIntersection(pickRay, true, [_this.entityID]);
|
||||||
|
|
||||||
var intersectionDistance = Vec3.distance(pickRay.origin, intersection.intersection);
|
// print('INTERSCTION::: ' + JSON.stringify(intersection));
|
||||||
|
|
||||||
|
if (intersection.intersects && intersection.entityID === _this.entityID) {
|
||||||
|
print('intersecting a tank')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,7 +315,7 @@
|
||||||
|
|
||||||
|
|
||||||
var fish = _this.fish;
|
var fish = _this.fish;
|
||||||
print('how many fish do i find?' + fish.length)
|
// print('how many fish do i find?' + fish.length)
|
||||||
|
|
||||||
if (fish.length === 0) {
|
if (fish.length === 0) {
|
||||||
print('no fish...')
|
print('no fish...')
|
||||||
|
@ -505,6 +536,9 @@
|
||||||
_this.tankLocked = false;
|
_this.tankLocked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Script.scriptEnding.connect(function() {
|
||||||
|
Script.update.disconnect(_this.update);
|
||||||
|
})
|
||||||
|
|
||||||
return new FishTank();
|
return new FishTank();
|
||||||
});
|
});
|
Loading…
Reference in a new issue