-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pen optional rendering to the web proto viewer (#5635)
* abstract camera * buggy * advance but still buggy * working frustum * always enable * fix scrollbar and improve style * improvement (linescale + list of cameras) * enable and disable optional rendering * all parameters * display correctly rows * Update toolbar.css * style * cleanup * Update ProtoCamera.proto * Update ProtoCamera.proto * Update resources/web/wwi/nodes/WbAbstractCamera.js Co-authored-by: ad-daniel <[email protected]> * Update resources/web/wwi/nodes/WbCamera.js Co-authored-by: ad-daniel <[email protected]> * change color * parent * split in two methods * click and co * rangefinder * sanitize abstract camera * Revert "rangefinder" This reverts commit 8d43b63. * sanitize * renable hover correctly * Revert "Revert "rangefinder"" This reverts commit 83804e5. * fix near sanitization * color * improve style * correct color * progress lidar * progress * progress * progress * progress * finish lidar * const * cleanup lidar and abstract camera * code done, but not working * style * working * udpates * lightSensor * name * cleanup * pen Co-authored-by: ad-daniel <[email protected]> Co-authored-by: Olivier Michel <[email protected]>
- Loading branch information
1 parent
15360f2
commit fcab6e4
Showing
11 changed files
with
95 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,82 @@ | ||
import WbSolid from './WbSolid.js'; | ||
import WbWrenRenderingContext from '../wren/WbWrenRenderingContext.js'; | ||
import WbWrenShaders from '../wren/WbWrenShaders.js'; | ||
import {arrayXPointerFloat} from './utils/utils.js'; | ||
|
||
// This class is used to retrieve the type of device | ||
export default class WbPen extends WbSolid { | ||
#material; | ||
#mesh; | ||
#renderable; | ||
#transform; | ||
#write; | ||
constructor(id, translation, scale, rotation, name, write) { | ||
super(id, translation, scale, rotation, name); | ||
this.#write = write; | ||
} | ||
|
||
get write() { | ||
return this.#write; | ||
} | ||
|
||
set write(newWrite) { | ||
this.#write = newWrite; | ||
this.#update(); | ||
} | ||
|
||
createWrenObjects() { | ||
super.createWrenObjects(); | ||
|
||
const coords = [0, 0, -1, 0, 0, 0]; | ||
const coordsPointer = arrayXPointerFloat(coords); | ||
this.#transform = _wr_transform_new(); | ||
this.#renderable = _wr_renderable_new(); | ||
this.#material = _wr_phong_material_new(); | ||
|
||
this.#mesh = _wr_static_mesh_line_set_new(2, coordsPointer, undefined); | ||
_free(coordsPointer); | ||
|
||
const color = _wrjs_array3(0.5, 0.5, 0.5); | ||
_wr_phong_material_set_color(this.#material, color); | ||
_wr_material_set_default_program(this.#material, WbWrenShaders.lineSetShader()); | ||
|
||
_wr_renderable_set_drawing_mode(this.#renderable, Enum.WR_RENDERABLE_DRAWING_MODE_LINES); | ||
_wr_renderable_set_mesh(this.#renderable, this.#mesh); | ||
_wr_renderable_set_material(this.#renderable, this.#material, undefined); | ||
_wr_renderable_set_cast_shadows(this.#renderable, false); | ||
_wr_renderable_set_receive_shadows(this.#renderable, false); | ||
_wr_renderable_set_visibility_flags(this.#renderable, WbWrenRenderingContext.VM_REGULAR); | ||
|
||
_wr_transform_attach_child(this.#transform, this.#renderable); | ||
_wr_transform_attach_child(this.wrenNode, this.#transform); | ||
_wr_node_set_visible(this.#transform, false); | ||
|
||
this.#applyOptionalRenderingToWren(); | ||
} | ||
|
||
applyOptionalRendering(enable) { | ||
_wr_node_set_visible(this.#transform, enable); | ||
} | ||
|
||
#applyOptionalRenderingToWren() { | ||
if (!this.wrenObjectsCreatedCalled) | ||
return; | ||
|
||
const lineScale = _wr_config_get_line_scale(); | ||
const scale = _wrjs_array3(lineScale, lineScale, lineScale); | ||
_wr_transform_set_scale(this.#transform, scale); | ||
|
||
if (this.#write) { | ||
const enabledColor = _wrjs_array3(0.5, 0, 1); | ||
_wr_phong_material_set_color(this.#material, enabledColor); | ||
} else { | ||
const disabledColor = _wrjs_array3(0.5, 0.5, 0.5); | ||
_wr_phong_material_set_color(this.#material, disabledColor); | ||
} | ||
} | ||
|
||
#update() { | ||
if (this.wrenObjectsCreatedCalled) | ||
this.#applyOptionalRenderingToWren(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters