Changing color of existing sheets

Apr 26, 2013 at 10:25 AM
Hello, i tried a search but i think there is no other topic for that..

However, i modified the basic creating a scene example, and extended it b functions such as to build a building as one function and determining wheter your clicking on a building or not, and if so, tell me which id the building has. It was alot of math and trying to get that work. My main point that i want to ask is, is it possible to change then the sheetcolors of my clicked building? I have a "global" object called buildings, where all the buildings are stored in javascript. But how can i adjust the properties of one of these?

Thanks in advance!
Apr 28, 2013 at 9:20 PM
there is an example on how to detect if an object is hovered/clicked by the mouse in the examples and also in the documentation:
This example calculates if the single object in the scene has been clicked or not, but this can be easily extended to multiple objects. Once you have the object reference in your hand upon click you can do whatever you want to do with it. It is a single SheetObject, you can move it (like in the example), you can rotate it, you can draw on the 2D context of the main canvas (in the example we draw a rectangle upon hover) and you can also manipulate the object's sheets, or draw on the object's sheets, just like shown in the other examples.
Apr 29, 2013 at 10:22 AM

Thansk for your answer, but that thing with selecting wasnt what i needed. I ended up writing an algorithm with my collegue to determine wheter a 3d building is clicked or not. The problem is, i cant figure out how to change properties of a building and redraw the scene...
Apr 29, 2013 at 1:00 PM
Look at the examples on moving/rotating objects and animating objects. Once you have a reference to the object in question in your hand, it should not be a big deal to do some stuff with them. The corresponding documentation:

To access the individual sheets of an object, simply use the sheets array:
var sheets = obj.sheets;
To draw something on the sheet, simply use its HTML5 canvas context:
sheet.context.fillStyle = '#F00';
sheet.context.fillRect(state * 10,0,10,10);
sheet.canvasChanged(); // call this when done with drawing
To redraw the whole scene call the following methods:
Apr 29, 2013 at 2:10 PM
Okey i got it to work. Now i only have one problem left. If i color the buildings (they initially have a color of 90% opacity of white) to another color, some of the other buildings lose their opacity and switch to fulltone (100% opacity)

may that be a bug caused by my code or did you already get an issue like that from another user?
Apr 29, 2013 at 2:32 PM
I have not yet received any issues that could be related. If you find that it is a bug in the engine, let me know. I haven't tested the engine thoroughly with semi-transparent colors, but there should not be any problems with them (maybe some issues with shadows). Send me repro steps or example code if you find its a bug in the engine, that would be helpful.