maxkrieger / aframe-draw-component Goto Github PK
View Code? Open in Web Editor NEWHTML5 canvas component for AFrame VR.
Home Page: http://a9.io/aframe-draw-component/
HTML5 canvas component for AFrame VR.
Home Page: http://a9.io/aframe-draw-component/
Would it be faster to set the texture directly from the canvas by manipulating the Object3D.material?
Hi,
Great component.. thanks.
I've picked this up from en existing project and I'm trying to enable updating an element, This component is working the first time, but after I try and update it just turns into a white box.
Here is my component:
`AFRAME.registerComponent('hotspots-button', {
dependencies: ['draw'],
schema: {
text: {type: 'string', default: ''},
icon: {type: 'string', default: ''},
},
_imageURL: '',
init: function() {
this.draw = this.el.components.draw
this.draw.register(this.render.bind(this))
},
update: function () {
this.draw.render()
this.el.children[0].setAttribute('src', this._imageURL)
},
render: function () {
let ctx = this.draw.ctx
let canvas = this.draw.canvas
blackCurvedImage(canvas, ctx, canvas.width, canvas.height, this.data.text)
this._imageURL = canvas.toDataURL('image/png',1.0)
},
})`
The blackCurvedImage function makes the changes to the canvas i.e.
export function blackCurvedImage(canvas, ctx, width, height, text) {
// Clean context
ctx.clearRect(0, 0, width, height)
// Container
ctx.strokeStyle = classicWhiteOutlineRGBA
ctx.fillStyle = classicBlackFillRGBA
roundRect(ctx, 0, 0, width, height, 20, true)
...
However changes are not being reflected.
Currently it's just turning the canvas white.
Any ideas on how to manage updates?
Getting CORS errors. Is there a workaround?
I tried sending the data URL to an <img>
with crossorigin
, and then reading from that, but that didn't work.
npm run dist
should build dist files so we can download droppable files into HTML.
Hi,
The components works perfectly if using aframe-core, as you have in your package
"aframe-core": "0.1.2",
but the with the latest aframe branch
"aframe": "aframevr/aframe#dev"
The canvas is not drawn on the entity and I didn't get any message on the console about it.
I want to do it by es6 import:
import 'aframe'
import 'aframe-draw-component'
but I fount that It didn't add draw in AFRAME components.
How to import it and use it with advanced usage?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.