/editor/test/integration/collada_scene_test.clj

https://github.com/defold/defold · Clojure · 46 lines · 30 code · 5 blank · 11 comment · 2 complexity · ff410c7db98423f084a0b3175fd3c972 MD5 · raw file

  1. ;; Copyright 2020 The Defold Foundation
  2. ;; Licensed under the Defold License version 1.0 (the "License"); you may not use
  3. ;; this file except in compliance with the License.
  4. ;;
  5. ;; You may obtain a copy of the License, together with FAQs at
  6. ;; https://www.defold.com/license
  7. ;;
  8. ;; Unless required by applicable law or agreed to in writing, software distributed
  9. ;; under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
  10. ;; CONDITIONS OF ANY KIND, either express or implied. See the License for the
  11. ;; specific language governing permissions and limitations under the License.
  12. (ns integration.collada-scene-test
  13. (:require [clojure.test :refer :all]
  14. [dynamo.graph :as g]
  15. [integration.test-util :as test-util]
  16. [editor.collada-scene :as collada-scene]
  17. [editor.math :as math]
  18. [editor.types :as types])
  19. (:import [javax.vecmath Point3d]))
  20. (deftest aabb
  21. (test-util/with-loaded-project
  22. (let [node-id (test-util/resource-node project "/mesh/test.dae")
  23. aabb (g/node-value node-id :aabb)
  24. min ^Point3d (types/min-p aabb)
  25. max ^Point3d (types/max-p aabb)
  26. dist (.distance max min)]
  27. (is (and (> 20 dist) (< 10 dist))))))
  28. (deftest vbs
  29. (test-util/with-loaded-project
  30. (let [node-id (test-util/resource-node project "/mesh/test.dae")
  31. mesh (first (g/node-value node-id :meshes))
  32. scene (g/node-value node-id :scene)
  33. user-data (get-in scene [:renderable :user-data])
  34. vb (-> (collada-scene/->vtx-pos-nrm-tex (alength (get-in user-data [:meshes 0 :position-indices])))
  35. (collada-scene/mesh->vb! (math/->mat4) :vertex-space-world mesh (get user-data :scratch-arrays)))]
  36. (is (= (count vb) (alength (get mesh :position-indices)))))))
  37. (deftest invalid-scene
  38. (test-util/with-loaded-project
  39. (let [node-id (test-util/resource-node project "/mesh/invalid.dae")
  40. scene (g/node-value node-id :scene)]
  41. (is (g/error? scene)))))