Skip to content

Commit

Permalink
Fix wrong material ID in Material Editor.
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelTallet committed Apr 18, 2018
1 parent 14f08ec commit 2f0dd77
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 17 deletions.
2 changes: 1 addition & 1 deletion source/pbr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# PBR plugin namespace.
module PBR

VERSION = '1.2.1'.freeze
VERSION = '1.2.2'.freeze

# Homepage's URL. Thanks to GitHub for hosting and tools.
HOMEPAGE_URL = 'https://github.com/SamuelTS/SketchUp-PBR-Plugin'.freeze
Expand Down
2 changes: 1 addition & 1 deletion source/pbr/HTML Dialogs/material-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ PBR.materials = [];
* @returns {object}
*/
PBR.selectedMaterial = () => PBR.materials[
document.getElementById('material-selector').selectedIndex
document.getElementById('material-selector').value
];

/**
Expand Down
4 changes: 2 additions & 2 deletions source/pbr/HTML Dialogs/material-editor.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
# Identifier of selected material in Materials Tray.
selected_material_oid = Sketchup.active_model.materials.current.object_id

Sketchup.active_model.materials.each_with_index do |material, material_index|
Sketchup.active_model.materials.each do |material|
%>
<option
value="<%= material_index %>"
value="<%= material.object_id %>"
<%= material.object_id == selected_material_oid ? 'selected' : '' %>
>
<%= material.display_name %>
Expand Down
20 changes: 20 additions & 0 deletions source/pbr/Web Server/html/assets/cayley_interior_2k.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
HDRI License
All HDRIs on this site are licensed as CC0 - which is the most liberal license I know of.

Here's an exerpt from the CC0 FAQ page to clarify:

Once the creator or a subsequent owner of a work applies CC0 to a work, the work is no longer his or hers in any meaningful sense under copyright law. Anyone can then use the work in any way and for any purpose, including commercial purposes, subject to other laws and the rights others may have in the work or how the work is used. Think of CC0 as the "no rights reserved" option. CC0 is a useful tool for clarifying that you do not claim copyright in a work anywhere in the world.
In other words, these HDRIs no longer belong to me. They belong to the public.

Because you might feel the need to ask anyway:

You can use the HDRIs for any purpose, including commercial.
You do not need to give credit or attribution when using them (although it is appreciated).
You can redistribute them (share them around or include them when sharing your own project).
The only thing you can't do is claim to be the author of the HDRIs. Since they are Public Domain, no one owns them.

More info: CC0 summary, CC0 wiki, CC0 FAQ.

If you have any questions, feel free to email me at [email protected]

Disclaimer: occasionally a brand name, logo or other copyrighted design may appear in the HDRIs. It is the responsibility of the user not to infringe on these copyrights in their own work.
Binary file not shown.
1 change: 0 additions & 1 deletion source/pbr/Web Server/html/assets/pisa.COPYRIGHT

This file was deleted.

Binary file removed source/pbr/Web Server/html/assets/pisa.modded.hdr
Binary file not shown.
1 change: 0 additions & 1 deletion source/pbr/Web Server/html/assets/sketchup-model.gltf

This file was deleted.

7 changes: 4 additions & 3 deletions source/pbr/Web Server/html/viewport.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,10 @@ PBR.Viewport.app = clay.application.create('.container', {
// Create an ambient light.
app.createAmbientCubemapLight(

'/assets/pisa.modded.hdr', // Panorama environment image.
1, // Intensity of specular light.
1 // Intensity of diffuse light.
// Panorama environment image.
'/assets/cayley_interior_2k.hdr',
1, // Intensity of specular light.
1 // Intensity of diffuse light.

);

Expand Down
16 changes: 8 additions & 8 deletions source/pbr/material_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@ def show

# Collects SketchUp materials attributes to edit in PBR Material Editor.
#
# @param [Array] mats_to_edit Materials to edit. Default: Empty array.
# @param [Hash] mats_to_edit Materials to edit. Default: Empty hash.
#
# @return [Array<Hash>] Materials to edit. Caution! Array index matters.
private def materials_to_edit(mats_to_edit = [])
# @return [Hash<Hash>] Materials to edit.
private def materials_to_edit(mats_to_edit = {})

# For each SketchUp material in active model:
Sketchup.active_model.materials.each_with_index do |mat, mat_index|
Sketchup.active_model.materials.each do |mat|

mats_to_edit[mat_index] = {
mats_to_edit[mat.object_id] = {

# Get PBR plugin attributes to edit.

Expand Down Expand Up @@ -176,15 +176,15 @@ def show

# Syncs SketchUp materials with attributes edited in PBR Material Editor.
#
# @param [Array<Hash>] edited_mats Edited materials.
# @param [Hash<Hash>] edited_mats Edited materials.
#
# @return [void]
private def edited_materials=(edited_mats)

# For each edited material...
edited_mats.each_with_index do |mat_attributes, mat_index|
edited_mats.each do |mat_object_id, mat_attributes|

material = Sketchup.active_model.materials[mat_index]
material = ObjectSpace._id2ref(mat_object_id.to_i)

# attribute:
mat_attributes.each do |mat_attr_key, mat_attr_value|
Expand Down

0 comments on commit 2f0dd77

Please sign in to comment.