MCPcopy
hub / github.com/aframevr/aframe / createRay

Function createRay

src/components/laser-controls.js:38–69  ·  view source on GitHub ↗
(evt)

Source from the content-addressed store, hash-verified

36 });
37
38 function createRay (evt) {
39 var controllerConfig = config[evt.detail.name];
40
41 if (!controllerConfig) { return; }
42
43 // Show the line unless a particular config opts to hide it, until a controllermodelready
44 // event comes through.
45 var raycasterConfig = utils.extend({
46 showLine: true
47 }, controllerConfig.raycaster || {});
48
49 // The controllermodelready event contains a rayOrigin that takes into account
50 // offsets specific to the loaded model.
51 if (evt.detail.rayOrigin) {
52 raycasterConfig.origin = evt.detail.rayOrigin.origin;
53 raycasterConfig.direction = evt.detail.rayOrigin.direction;
54 raycasterConfig.showLine = true;
55 }
56
57 // Only apply a default raycaster if it does not yet exist. This prevents it overwriting
58 // config applied from a controllermodelready event.
59 if (evt.detail.rayOrigin || !self.modelReady) {
60 el.setAttribute('raycaster', raycasterConfig);
61 } else {
62 el.setAttribute('raycaster', 'showLine', true);
63 }
64
65 el.setAttribute('cursor', utils.extend({
66 fuse: false,
67 hand: data.hand
68 }, controllerConfig.cursor));
69 }
70
71 function hideRay (evt) {
72 var controllerConfig = config[evt.detail.name];

Callers 1

laser-controls.jsFile · 0.85

Calls 2

extendMethod · 0.80
setAttributeMethod · 0.45

Tested by

no test coverage detected