Compare commits

...

3 Commits

Author SHA1 Message Date
izzy lyseggen 520dccc674 fix(convert): traverse all base props
not just dynamically detached ones
2021-11-09 18:19:43 +00:00
izzy lyseggen 22e6ea7515 fix(ui): init apollo url 2021-11-09 14:40:07 +00:00
izzy lyseggen 81af3da8b4 feat(build): rel paths for build and puts logging 2021-11-09 11:17:08 +00:00
5 changed files with 36 additions and 21 deletions
+2
View File
@@ -21,6 +21,8 @@ module SpeckleSystems
# Run from localhost or from build files
DEV_MODE = false
puts("Loading Speckle Connector v#{CONNECTOR_VERSION} from #{DEV_MODE ? 'dev' : 'build'}")
unless file_loaded?(__FILE__)
+27 -13
View File
@@ -6,8 +6,7 @@ module SpeckleSystems::SpeckleConnector::ToNative
if can_convert_to_native(obj)
convert_to_native(obj, Sketchup.active_model.entities)
elsif obj.is_a?(Hash) && obj.key?("speckle_type")
props = obj.keys.filter_map { |key| key if key.start_with?("@") }
%w[displayMesh displayValue data].each { |prop| props.push(prop) if obj.key?(prop) }
props = obj.keys.filter_map { |key| key unless key.start_with?("_") }
props.each { |prop| traverse_commit_object(obj[prop]) }
elsif obj.is_a?(Hash)
obj.each_value { |value| traverse_commit_object(value) }
@@ -40,10 +39,10 @@ module SpeckleSystems::SpeckleConnector::ToNative
else
nil
end
# rescue StandardError => e
# puts("Failed to convert #{obj["speckle_type"]} (id: #{obj["id"]})")
# puts(e)
# nil
# rescue StandardError => e
# puts("Failed to convert #{obj["speckle_type"]} (id: #{obj["id"]})")
# puts(e)
# nil
end
def length_to_native(length, units = @units)
@@ -73,6 +72,8 @@ module SpeckleSystems::SpeckleConnector::ToNative
definition&.entities&.clear!
definition ||= Sketchup.active_model.definitions.add(block_def["name"])
block_def["geometry"].each { |obj| convert_to_native(obj, definition.entities) }
puts("definition finished: #{block_def["name"]} (#{block_def["id"]})")
puts(" entity count: #{definition.entities.count}")
definition
end
@@ -113,6 +114,10 @@ module SpeckleSystems::SpeckleConnector::ToNative
entities.add_instance(definition, transform)
end
puts("Failed to create instance for speckle object #{block["id"]}") if instance.nil?
if instance.nil?
p(definition.name)
p(definition.entities.to_a)
end
instance.transformation = transform if is_group
instance.material = material_to_native(block["renderMaterial"])
instance
@@ -121,13 +126,22 @@ module SpeckleSystems::SpeckleConnector::ToNative
def transform_to_native(t_arr, units = @units)
Geom::Transformation.new(
[
t_arr[0], t_arr[4], t_arr[8], t_arr[12],
t_arr[1], t_arr[5], t_arr[9], t_arr[13],
t_arr[2], t_arr[6], t_arr[10], t_arr[14],
length_to_native(t_arr[3], units),
length_to_native(t_arr[7], units),
length_to_native(t_arr[11], units),
t_arr[15]
t_arr[0],
t_arr[4],
t_arr[8],
t_arr[12],
t_arr[1],
t_arr[5],
t_arr[9],
t_arr[13],
t_arr[2],
t_arr[6],
t_arr[10],
t_arr[14],
length_to_native(t_arr[3], units),
length_to_native(t_arr[7], units),
length_to_native(t_arr[11], units),
t_arr[15]
]
)
end
+4 -4
View File
@@ -42,13 +42,13 @@ module SpeckleSystems::SpeckleConnector
init_local_accounts
end
puts DEV_MODE
if DEV_MODE
puts('Launching Speckle Connector from http://localhost:8081')
@dialog.set_url("http://localhost:8081")
else
basedir = File.join(File.dirname(File.expand_path(__FILE__)), "html")
html = File.read(File.join(basedir, "index.html"))
@dialog.set_html(html)
html_file = File.join(File.dirname(File.expand_path(__FILE__)), "html", "index.html")
puts("Launching Speckle Connector from #{html_file}")
@dialog.set_file(html_file)
end
@dialog.show
+2
View File
@@ -11,6 +11,8 @@ const AUTH_TOKEN = `SpeckleSketchup.AuthToken`
if (process.env.NODE_ENV === 'development') {
localStorage.setItem(AUTH_TOKEN, process.env.VUE_APP_DEV_TOKEN)
localStorage.setItem('serverUrl', process.env.VUE_APP_DEFAULT_SERVER)
} else if (!localStorage.getItem('serverUrl')) {
localStorage.setItem('serverUrl', 'https://speckle.xyz')
}
const authLink = setContext((_, { headers }) => {
+1 -4
View File
@@ -1,10 +1,7 @@
const path = require('path')
module.exports = {
publicPath:
process.env.NODE_ENV === 'production'
? path.resolve(__dirname, '../speckle_connector', 'html')
: '/',
publicPath: "./",
outputDir: path.resolve(__dirname, '../speckle_connector', 'html'),
transpileDependencies: ['vuetify', '@speckle/objectloader']
}