a-frame-components
Advanced tools
Comparing version 1.0.249 to 1.0.250
@@ -51,2 +51,3 @@ var __assign = (this && this.__assign) || function () { | ||
import { AFRAME } from '../systems/brush'; | ||
import { GrabAndDropEvents } from '../systems/grabanddrop'; | ||
import { drawTextureOnCanvas, raiseCustomEvent } from '../util'; | ||
@@ -57,5 +58,7 @@ var THREE = window.THREE; | ||
AFRAME.registerComponent('canvasimage', __assign(__assign({ schema: { | ||
category: { type: 'string' }, | ||
url: { type: 'string' }, | ||
height: { type: 'number', default: 1 } // Provide a default value for height | ||
} }, mixin), { init: function () { | ||
var _this = this; | ||
var me = this; | ||
@@ -71,2 +74,14 @@ var plane = document.createElement('a-plane'); | ||
this.loadImage(); | ||
plane.addEventListener(GrabAndDropEvents.DROPPED_GRABBED_DATA, function (evt) { return __awaiter(_this, void 0, void 0, function () { | ||
var _a, data, category; | ||
return __generator(this, function (_b) { | ||
_a = evt.detail, data = _a.data, category = _a.category; | ||
if (me.data.category === category) { | ||
if (data === null || data === void 0 ? void 0 : data.url) { | ||
me.el.setAttribute('url', data === null || data === void 0 ? void 0 : data.url); | ||
} | ||
} | ||
return [2 /*return*/]; | ||
}); | ||
}); }); | ||
}, update: function (oldData) { | ||
@@ -132,5 +147,6 @@ // Only update if url has changed | ||
url: 'canvasimage.url', | ||
height: 'canvasimage.height' | ||
height: 'canvasimage.height', | ||
category: 'canvasimage.category' | ||
} | ||
}); | ||
} |
{ | ||
"name": "a-frame-components", | ||
"version": "1.0.249", | ||
"version": "1.0.250", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -12,2 +12,3 @@ import mixin from '../../gui/components/mixin'; | ||
schema: { | ||
category: { type: 'string' }, | ||
url: { type: 'string' }, | ||
@@ -28,2 +29,11 @@ height: { type: 'number', default: 1 } // Provide a default value for height | ||
this.loadImage(); | ||
plane.addEventListener(GrabAndDropEvents.DROPPED_GRABBED_DATA, async (evt) => { | ||
const { data, category } = evt.detail; | ||
if (me.data.category === category) { | ||
if (data?.url) { | ||
me.el.setAttribute('url', data?.url); | ||
} | ||
} | ||
}) | ||
}, | ||
@@ -91,5 +101,6 @@ update: function (oldData) { | ||
url: 'canvasimage.url', | ||
height: 'canvasimage.height' | ||
height: 'canvasimage.height', | ||
category: 'canvasimage.category' | ||
} | ||
}); | ||
} |
1760931
30018