content/hifi-content/thoys/dev/2017/voxelPaintImprovements/voxel-paint-fixer.js
2022-02-14 02:04:11 +01:00

99 lines
3.5 KiB
JavaScript

Script.include('/~/system/libraries/utils.js');
var SCRIPT_ROOT_PATH = 'http://mpassets.highfidelity.com/8049e3c8-1cf5-4268-b608-91795d186008-v1/';
var shared = Script.require(SCRIPT_ROOT_PATH + 'voxel-paint-shared.js');
var dimension = 8;
var lifetime = 10; // -1
var addAether = function(platformID) {
var props = Entities.getEntityProperties(platformID, ['position', 'rotation', 'dimensions']);
var dimensions = props.dimensions;
var position = props.position;
position.y = position.y - (props.dimensions.y / 2) + this.floorThickness;
dimensions.y = this.dimension;
var aetherPosition = Vec3.sum(position, { x: 0, y: this.dimension / 2, z: 0 });
var properties = {
color: { red: 0, green: 0, blue: 0 },
dimensions: dimensions,
name: 'voxel paint aether',
position: aetherPosition,
rotation: props.rotation,
shape: 'Cube',
type: 'Box',
collidesWith: '',
collisionMask: 0,
collisionless: true,
visible: false,
script: Script.resolvePath('voxel-paint-aether.js'),
userData: JSON.stringify({ grabbableKey: {grabbable: false} })
};
if (shared.DEBUG) {
properties.scriptTimestamp = Date.now();
}
return Entities.addEntity(properties);
};
var addPaletteSpawner = function(position) {
var properties = Entities.getEntityProperties(this.entityID, ['position', 'rotation', 'dimensions']);
var pickRay = {
origin: properties.position,
direction: { x: 0.0, y: -1.0, z: 0.0 },
length: 3.0
};
var intersection = Entities.findRayIntersection(pickRay, true, [], [this.entityID],
true, // visibleOnly
true); // collidableOnly
var paletteSpawnerPosition;
if (intersection.intersects) {
paletteSpawnerPosition = Vec3.sum(properties.position, { x: 0, y: 1.1 - intersection.distance, z: 0 });
} else {
paletteSpawnerPosition = properties.position;
}
paletteSpawnerPosition = Vec3.sum(paletteSpawnerPosition, Vec3.multiplyQbyV(properties.rotation,
{ x: 1.0, y: 0.0, z: 1.0 }));
var paletteSpawnerProperties = {
dimensions: { x: 0.63, y: 0.63, z: 0.63 },
name: 'voxel paint palette spawner',
position: paletteSpawnerPosition,
script: Script.resolvePath('handyAttacher.js'),
type: 'Sphere',
collidesWith: '',
collisionMask: 0,
collisionless: true,
visible: false,
userData: JSON.stringify({
grabbableKey: {
wantsTrigger: true
}
})
};
if (shared.DEBUG) {
paletteSpawnerProperties.scriptTimestamp = Date.now();
}
var paletteSpawnerID = Entities.addEntity(paletteSpawnerProperties);
Entities.addEntity({
dimensions: {
x: 0.62574279308319092,
y: 0.023471139371395111,
z: 0.52269172668457031
},
modelURL: shared.MODELS_PATH + 'painter_Palette.fbx',
name: 'voxel paint palette spawner model',
parentID: paletteSpawnerID,
localPosition: { x: 0, y: 0, z: 0 },
shapeType: 'none',
collidesWith: '',
collisionMask: 0,
collisionless: true,
type: 'Model'
});
return paletteSpawnerID;
};
Entities.findEntitiesByType('Model', MyAvatar.position, 60000).forEach(function(entityID) {
if (Entities.getEntityProperties(entityID, 'name').name === 'voxel paint floor') {
}
});