Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unionise t-shirt #1

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "smoke.png",
"filename" : "1.png",
"idiom" : "universal",
"scale" : "1x"
},
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "2.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "3.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "4.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "5.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "6.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "7.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "8.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "reference2.png",
"filename" : "reference.png",
"idiom" : "universal"
}
],
Expand All @@ -11,6 +11,6 @@
},
"properties" : {
"unit" : "centimeters",
"width" : 10
"width" : 20
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "background.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "foreground.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
134 changes: 46 additions & 88 deletions ARKitImageDetection/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,99 +90,57 @@ class ViewController: UIViewController, ARSCNViewDelegate {
let imagePlaneNode = SCNNode()
imagePlaneNode.eulerAngles.x = -.pi / 2

// Smoke

let initialSmokeOpacity = 0.9

let smokePlane = SCNPlane(
width: 0.55 * referenceImage.physicalSize.width,
height: 0.55 * referenceImage.physicalSize.height
)

let smokeMaterial = SCNMaterial()
smokeMaterial.lightingModel = .constant
smokeMaterial.diffuse.contents = UIImage(named: "smoke")
smokePlane.firstMaterial = smokeMaterial

// Actions

let smokeInitialPosition = SCNVector3(
x: Float(CGFloat(0.25) * referenceImage.physicalSize.width),
y: Float(CGFloat(-0.11) * referenceImage.physicalSize.height),
z: 0
let backgroundPlane = SCNPlane(
width: referenceImage.physicalSize.width,
height: referenceImage.physicalSize.height
)

let fadeInAction = SCNAction.fadeOpacity(to: initialSmokeOpacity, duration: 0.25)

let leftAction = SCNAction.group([
.fadeOpacity(by: -0.10, duration: 0.25),
.moveBy(
x: CGFloat(-0.20) * referenceImage.physicalSize.width,
y: CGFloat(0.40) * referenceImage.physicalSize.height,
z: 0.01,
duration: 0.25
),
.scale(by: 1.25, duration: 0.25),
.rotateBy(x: 0, y: 0, z: .pi/10.0, duration: 0.25)
])

let rightAction = SCNAction.group([
.fadeOpacity(by: -0.10, duration: 0.25),
.moveBy(
x: CGFloat(0.20) * referenceImage.physicalSize.width,
y: CGFloat(0.40) * referenceImage.physicalSize.height,
z: 0.01,
duration: 0.25
),
.scale(by: 1.25, duration: 0.25),
.rotateBy(x: 0, y: 0, z: .pi/10.0, duration: 0.25)
])

let leftFadeOutAction = SCNAction.group([
.fadeOpacity(to: 0, duration: 0.25),
.moveBy(
x: CGFloat(-0.20) * referenceImage.physicalSize.width,
y: CGFloat(0.40) * referenceImage.physicalSize.height,
z: 0.01,
duration: 0.25
),
.scale(by: 1.25, duration: 0.25),
.rotateBy(x: 0, y: 0, z: .pi/10.0, duration: 0.25)
])

let resetAction = SCNAction.group([
.move(to: smokeInitialPosition, duration: 0),
.scale(to: 1, duration: 0),
.rotateTo(x: 0, y: 0, z: 0, duration: 0),
.fadeOpacity(to: 0, duration: 0)
])

let repeatingSequence = SCNAction.repeatForever(
.sequence([
fadeInAction,
rightAction,
leftAction,
rightAction,
leftAction,
rightAction,
leftFadeOutAction,
resetAction
])
)

// Additional smoke

for i in 0 ..< 7 {
let moreSmokePlaneNode = SCNNode(geometry: smokePlane)
moreSmokePlaneNode.position = smokeInitialPosition
moreSmokePlaneNode.opacity = 0

moreSmokePlaneNode.runAction(.sequence([
.wait(duration: 0.25 * Double(i)),
repeatingSequence
let backgroundMaterial = SCNMaterial()
backgroundMaterial.lightingModel = .constant
backgroundMaterial.diffuse.contents = UIImage(named: "background")
backgroundPlane.firstMaterial = backgroundMaterial

let backgroundPlaneNode = SCNNode(geometry: backgroundPlane)
backgroundPlaneNode.position = SCNVector3(x: 0, y: 0, z: 0)

imagePlaneNode.addChildNode(backgroundPlaneNode)

for i in 1...8 {
let nodePlane = SCNPlane(
width: referenceImage.physicalSize.width,
height: referenceImage.physicalSize.height
)

let nodeMaterial = SCNMaterial()
nodeMaterial.lightingModel = .constant
nodeMaterial.diffuse.contents = UIImage(named: "\(i)")
nodePlane.firstMaterial = nodeMaterial

let initialPosition = SCNVector3(x: 0, y: 0, z: 0.01)
let finalPosition = SCNVector3(x: 0, y: 0, z: 0.05)

let node = SCNNode(geometry: nodePlane)
node.position = initialPosition

let baseUnit = 0.4

node.runAction(.sequence([
.wait(duration: 0.5 * baseUnit * Double(i - 1)),
.repeatForever(.sequence([
.group([
.move(to: finalPosition, duration: baseUnit),
.scale(to: 1.125, duration: baseUnit)
]),
.group([
.move(to: initialPosition, duration: baseUnit),
.scale(to: 1, duration: baseUnit)
]),
.wait(duration: 3.5 * baseUnit)
]))
]))

imagePlaneNode.addChildNode(moreSmokePlaneNode)
imagePlaneNode.addChildNode(node)
}

// Add the plane visualization to the scene.
Expand Down